Fix assertion error in sql planning for latest aggregators#13151
Fix assertion error in sql planning for latest aggregators#13151abhishekagarwal87 merged 4 commits intoapache:masterfrom
Conversation
| maxStringBytes = RexLiteral.intValue(rexNodes.get(1)); | ||
| } | ||
| catch (AssertionError ae) { | ||
| plannerContext.setPlanningError("The second argument '%s' to '%s' function is not a literal", aggregateCall.getName(), rexNodes.get(1)); |
There was a problem hiding this comment.
The arguments to this formatted error message seem reversed.
There was a problem hiding this comment.
We can also safely say that the argument should be an integer (maybe also mention the name of the argument) rather than saying that it should be a "literal".
| } | ||
|
|
||
| @Test | ||
| public void testStringLatestByGroupByWithAlwaysFalseCondition() |
There was a problem hiding this comment.
Nit: Maybe also add a test case to verify error message?
There was a problem hiding this comment.
I was not able to figure out a query that gets me that error message. This query is not an invalid query. It just goes through a bad stage and doesn't recover before this fix. Now it can.
There was a problem hiding this comment.
Perhaps a LATEST(dim4, "100") but it's not essential, we can do it later.
There was a problem hiding this comment.
that SQL will generate a different error and fails even before reaching the SqlAggregagtor.
| case 3: | ||
| int maxStringBytes; | ||
| try { | ||
| maxStringBytes = RexLiteral.intValue(rexNodes.get(2)); |
There was a problem hiding this comment.
From the docs, it seems that maxBytesPerString is always the second argument, i.e. rexNodes.get(1)
There was a problem hiding this comment.
For EARLIEST_BY/LATEST_BY, it's the third argument. For non _BY aggregators, it's second argument.
There was a problem hiding this comment.
I fixed the error message though.
There was a problem hiding this comment.
Thanks for the clarification, I was looking at an older doc in the original PR.
kfaraz
left a comment
There was a problem hiding this comment.
Thanks for the fix, @abhishekagarwal87 !
| case 3: | ||
| int maxStringBytes; | ||
| try { | ||
| maxStringBytes = RexLiteral.intValue(rexNodes.get(2)); |
There was a problem hiding this comment.
Thanks for the clarification, I was looking at an older doc in the original PR.
| } | ||
|
|
||
| @Test | ||
| public void testStringLatestByGroupByWithAlwaysFalseCondition() |
There was a problem hiding this comment.
Perhaps a LATEST(dim4, "100") but it's not essential, we can do it later.
|
Merged since build failure is unrelated. |
* Fix sql planning bug for latest aggregators * change test name * Fix error messages * fix error message again
Fixes #13091.
This PR has: