-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CALCITE-4207] Validation fails for positional aggregate with current_date in 'case' expression #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…_date in 'case' expression
1c19c4a
to
bc13e00
Compare
} | ||
}; | ||
sql("SELECT HIREDATE >= CURRENT_DATE, COUNT(*) " | ||
+ "FROM EMP GROUP BY 1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by why the current_date
caused the problem, does other non-param function triggers the bug too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the stack trace from CALCITE-4207 description and this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In one place CURRENT_DATE was represented as SqlBasicCall while in other it was instance of SqlIdentifier
Still does not get your point, in you fix, you just use the expanded group expr for validation, but the CURRENT_DATE
is not a group expr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Positional aggregate points to the first expression in select. Validation tries to match 2 expression trees :
- The first item from select which is already expanded at the moment and contains current_date as an instance of SqlBasicCall
- An item from the group by where prior to my fix current_date was presented as an instance of the SqlIdentifier.
Due to this instance mismatch validation goes further and tells that Expression 'EMP.HIREDATE' is not being grouped
, although grouping was performed by the whole expression HIREDATE >= CURRENT_DATE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @danny0405 , could you proceed with reviewing the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the fix locally and think the fix is reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review:)
Hello @zabetak , Could you please take a look at the PR? Thank you in advance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
+1 |
No description provided.