fix: add column-type precondition check in isFitForNonScanBasedPlan for MINLONG/MAXLONG/MINSTRING/MAXSTRING - #19146
Open
waterWang wants to merge 1 commit into
Conversation
…or MINLONG/MAXLONG/MINSTRING/MAXSTRING (apache#19145) The non-scan (metadata/dictionary based) aggregation path treats MINLONG, MAXLONG, MINSTRING, and MAXSTRING as resolvable if the column merely has a dictionary, without checking the column type is one the function actually supports. This causes: - MINLONG/MAXLONG over FLOAT/DOUBLE/BIG_DECIMAL: IllegalArgumentException (the non-scan path is too strict) - MINSTRING/MAXSTRING over numeric columns: silently returns wrong result from dictionary (the non-scan path is too lax) Fix: Add type precondition checks in isFitForNonScanBasedPlan() so unsupported combinations fall back to the scan path: - MINLONG/MAXLONG: require stored type INT or LONG - MINSTRING/MAXSTRING: require stored type STRING
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #19145
The non-scan (metadata/dictionary based) aggregation path treats
MINLONG,MAXLONG,MINSTRING, andMAXSTRINGas resolvable if the column merely has a dictionary, without checking that the column type is one the function actually supports. This causes inconsistent behavior:MINLONG/MAXLONGoverFLOAT/DOUBLE/BIG_DECIMAL:IllegalArgumentExceptionis thrown (the non-scan path is too strict — the scan path computes the result fine).MINSTRING/MAXSTRINGover numeric columns: silently returns a wrong result from the dictionary (the non-scan path is too lax — the scan path correctly rejects withBadQueryRequestException).Fix
Add type precondition checks in
isFitForNonScanBasedPlan()so unsupported column-type combinations fall back to the scan path:MINLONG/MAXLONG: require stored typeINTorLONGMINSTRING/MAXSTRING: require stored typeSTRINGTesting
MINLONG(doubleCol),MAXLONG(doubleCol),MINSTRING(intCol),MAXSTRING(intCol)on a single dictionary-encoded column with no filter now correctly fall back to the scan path, matching the behavior of mixed queries likeMINLONG(doubleCol), SUM(intCol).