Skip to content

refactor(testing): Move testMapBlockBug to TestExpressionInterpreter#27019

Closed
pramodsatya wants to merge 1 commit intoprestodb:masterfrom
pramodsatya:block_bug_test
Closed

refactor(testing): Move testMapBlockBug to TestExpressionInterpreter#27019
pramodsatya wants to merge 1 commit intoprestodb:masterfrom
pramodsatya:block_bug_test

Conversation

@pramodsatya
Copy link
Contributor

@pramodsatya pramodsatya commented Jan 23, 2026

Description

testMapBlockBug was added in 91efd78 and it tests expression interpreter functionality. Moves this test from AbstractTestQueries to AbstractTestExpressionInterpreter.

Motivation and Context

Tests from AbstractTestQueries are used in external test suites like presto-native-tests, where this test is not relevant. This refactor will help cleanup the test suite for #23671.

Impact

NA

== NO RELEASE NOTE ==

Summary by Sourcery

Tests:

  • Relocate the map block bug regression test from AbstractTestQueries to AbstractTestExpressionInterpreter.

Copilot AI review requested due to automatic review settings January 23, 2026 02:09
@pramodsatya pramodsatya requested review from a team, elharo and feilong-liu as code owners January 23, 2026 02:09
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Jan 23, 2026
@prestodb-ci prestodb-ci requested review from a team, NivinCS and nishithakbhaskaran and removed request for a team and Copilot January 23, 2026 02:09
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Moves 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

Change Details Files
Relocate the map block regression test into the expression interpreter test suite and adapt it to test interpreter behavior directly instead of query execution.
  • Add testMapBlockBug to AbstractTestExpressionInterpreter to assert that optimizing a malformed MAP_AGG expression throws a RuntimeException
  • Remove testMapBlockBug from AbstractTestQueries, which previously asserted a query failure for MAP_AGG via assertQueryFails
presto-main-base/src/test/java/com/facebook/presto/sql/expressions/AbstractTestExpressionInterpreter.java
presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestQueries.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pramodsatya
Copy link
Contributor Author

@aditi-pandit, @tdcmeehan, could you please help review this change?

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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))"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@pramodsatya
Copy link
Contributor Author

Thanks @tdcmeehan, after addressing the review comment from @sourcery-ai, further changes are needed, closing till further investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants