refactor(testing): Move testMapBlockBug to TestExpressionInterpreter#27019
refactor(testing): Move testMapBlockBug to TestExpressionInterpreter#27019pramodsatya wants to merge 1 commit intoprestodb:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMoves the map block regression test from the high-level query tests to the expression interpreter tests, adapting it from a query-failure assertion to a direct interpreter optimization failure assertion. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@aditi-pandit, @tdcmeehan, could you please help review this change? |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The ported
testMapBlockBugis now asserting only on a genericRuntimeExceptionand changed the expression (extra closing parenthesis and noVALUESwrapper), which risks no longer validating the original regression condition; consider aligning the expression and expected failure message/type with the original test to ensure the same behavior is being covered.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The ported `testMapBlockBug` is now asserting only on a generic `RuntimeException` and changed the expression (extra closing parenthesis and no `VALUES` wrapper), which risks no longer validating the original regression condition; consider aligning the expression and expected failure message/type with the original test to ensure the same behavior is being covered.
## Individual Comments
### Comment 1
<location> `presto-main-base/src/test/java/com/facebook/presto/sql/expressions/AbstractTestExpressionInterpreter.java:1539` </location>
<code_context>
+ @Test
+ public void testMapBlockBug()
+ {
+ assertThrows(RuntimeException.class, () -> optimize("MAP_AGG(12345,123))"));
+ }
+
</code_context>
<issue_to_address>
**suggestion (testing):** Preserve the original failure contract by asserting on exception message (and possibly type), not just RuntimeException
The previous test asserted the error message matched `"(?s).*Cannot evaluate non-scalar function.*"`, while this one only checks that a `RuntimeException` is thrown. That reduces regression coverage, since unrelated failures could still satisfy the test. Please also assert on the message (e.g., via `getMessage()` and the same pattern) and/or use a more specific exception type, possibly via a small helper similar to `assertQueryFails` for the expression interpreter layer.
Suggested implementation:
```java
@Test
public void testMapBlockBug()
{
try {
optimize("MAP_AGG(12345,123))");
fail("Expected RuntimeException to be thrown");
}
catch (RuntimeException e) {
assertTrue(
e.getMessage() != null && e.getMessage().matches("(?s).*Cannot evaluate non-scalar function.*"),
"Unexpected exception message: " + e.getMessage());
}
}
```
If `fail` and `assertTrue` are not already statically imported in this file, add:
- `import static org.testng.Assert.fail;`
- `import static org.testng.Assert.assertTrue;`
(or the equivalent for the assertion framework used in this test class).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @Test | ||
| public void testMapBlockBug() | ||
| { | ||
| assertThrows(RuntimeException.class, () -> optimize("MAP_AGG(12345,123))")); |
There was a problem hiding this comment.
suggestion (testing): Preserve the original failure contract by asserting on exception message (and possibly type), not just RuntimeException
The previous test asserted the error message matched "(?s).*Cannot evaluate non-scalar function.*", while this one only checks that a RuntimeException is thrown. That reduces regression coverage, since unrelated failures could still satisfy the test. Please also assert on the message (e.g., via getMessage() and the same pattern) and/or use a more specific exception type, possibly via a small helper similar to assertQueryFails for the expression interpreter layer.
Suggested implementation:
@Test
public void testMapBlockBug()
{
try {
optimize("MAP_AGG(12345,123))");
fail("Expected RuntimeException to be thrown");
}
catch (RuntimeException e) {
assertTrue(
e.getMessage() != null && e.getMessage().matches("(?s).*Cannot evaluate non-scalar function.*"),
"Unexpected exception message: " + e.getMessage());
}
}If fail and assertTrue are not already statically imported in this file, add:
import static org.testng.Assert.fail;import static org.testng.Assert.assertTrue;
(or the equivalent for the assertion framework used in this test class).
|
Thanks @tdcmeehan, after addressing the review comment from @sourcery-ai, further changes are needed, closing till further investigation. |
Description
testMapBlockBugwas added in 91efd78 and it tests expression interpreter functionality. Moves this test fromAbstractTestQueriestoAbstractTestExpressionInterpreter.Motivation and Context
Tests from
AbstractTestQueriesare used in external test suites likepresto-native-tests, where this test is not relevant. This refactor will help cleanup the test suite for #23671.Impact
NA
Summary by Sourcery
Tests: