[BugFix] Fix eventstats/streamstats rejecting window ranking functions (#5168)#22
[BugFix] Fix eventstats/streamstats rejecting window ranking functions (#5168)#22qianheng-aws wants to merge 2 commits intorefactor/dedupe-reusable-workflowfrom
Conversation
…pensearch-project#5269) (opensearch-project#5293) When querying across indices with conflicting field mappings (boolean vs text), numeric values like 0 were not coerced to boolean, causing "node must be a boolean, found NUMBER" error. Added numeric handling to parseBooleanValue() consistent with ObjectContent.booleanValue(). Signed-off-by: Heng Qian <qianheng@amazon.com>
opensearch-project#5168) Add row_number, rank, and dense_rank to WINDOW_FUNC_MAPPING so that eventstats/streamstats recognize them as valid window functions. Also add RANK and DENSE_RANK cases in PlanUtils.makeOver and skip aggregate signature validation for no-arg ranking functions. Signed-off-by: Heng Qian <qianheng@amazon.com>
Decision LogRoot Cause: Approach: Three-part fix: (1) Added the three ranking functions to Alternatives Rejected: Registering Pitfalls: The initial streamstats unit tests expected Things to Watch: Other no-arg window functions from the grammar ( |
|
Please add a test for the null input edge case — the current tests only cover happy path values. What happens if the window function receives null arguments? |
|
The error message here could be more descriptive. Instead of a generic message, include the field name and expected type when a ranking function is not found in the mapping. |
|
Consider handling the empty string case — what happens if the user passes an empty string to the partition-by clause of row_number()? |
|
Regarding the three review comments: 1. "Null input edge case test": These ranking functions ( 2. "More descriptive error message": The existing error 3. "Empty string in partition-by": The No code changes needed for these comments. |
|
Have duplicate fix now: opensearch-project#5305 |
|
Ah, I see. Is this PR used for testing workflow? |
Description
eventstats/streamstats rejected
row_number(),rank(), anddense_rank()window functionswith "Unexpected window function" errors even though the grammar accepts them.
Root cause: These ranking functions were missing from
WINDOW_FUNC_MAPPINGinBuiltinFunctionName.java, soCalciteRexNodeVisitor.visitWindowFunction()could notresolve them. Additionally,
RANKandDENSE_RANKhad no explicit cases inPlanUtils.makeOver().Fix:
row_number,rank,dense_ranktoWINDOW_FUNC_MAPPINGRANKandDENSE_RANKcases inPlanUtils.makeOver()usingSqlStdOperatorTablevalidateAggFunctionSignature()since they have no field arguments to validateRelated Issues
Resolves opensearch-project#5168
Check List
-s)spotlessCheckpassed