Skip to content

Conversation

qianheng-aws
Copy link
Collaborator

@qianheng-aws qianheng-aws commented Oct 15, 2025

Description

Fix push down failure for min/max on derived field

#4281 introduced below code for MIN/MAX in AggregateAnalyzer::createRegularAggregation

 String fieldName = helper.inferNamedField(args.getFirst()).getRootName();
        ExprType fieldType = helper.fieldTypes.get(fieldName);

which will throw NPE for derived fields, and then fails to push dow the agg.

Related Issues

Resolves #4571, #4460

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
LantaoJin
LantaoJin previously approved these changes Oct 16, 2025
# Conflicts:
#	integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java
@yuancu yuancu merged commit 0257aa5 into opensearch-project:main Oct 17, 2025
33 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.19-dev failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-4572-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0257aa5d51f044f3287bbaffc83aa72f8960c57c
# Push it to GitHub
git push --set-upstream origin backport/backport-4572-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-dev

Then, create a pull request where the base branch is 2.19-dev and the compare/head branch is backport/backport-4572-to-2.19-dev.

qianheng-aws added a commit to qianheng-aws/sql that referenced this pull request Oct 20, 2025
…t#4572)

(cherry picked from commit 0257aa5)
Signed-off-by: Heng Qian <qianheng@amazon.com>
qianheng-aws added a commit that referenced this pull request Oct 20, 2025
#4572) (#4601)

* Fix push down failure for min/max on derived field (#4572)

(cherry picked from commit 0257aa5)
Signed-off-by: Heng Qian <qianheng@amazon.com>

* Fix compiling

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Fix compiling

Signed-off-by: Heng Qian <qianheng@amazon.com>

* fix IT

Signed-off-by: Heng Qian <qianheng@amazon.com>

---------

Signed-off-by: Heng Qian <qianheng@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Min/Max on derived fields cannot be pushed down

3 participants