-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-6570] Add SCALAR_QUERY to sourceExpressionList of SqlUpdate #3966
base: main
Are you sure you want to change the base?
Conversation
7ae1fac
to
54216ca
Compare
54216ca
to
f29d170
Compare
@@ -2941,6 +2941,12 @@ private void registerQuery( | |||
SqlSelect.HAVING_OPERAND); | |||
registerSubQueries(selectScope2, | |||
SqlNonNullableAccessors.getSelectList(select)); | |||
|
|||
if (enclosingNode.getKind() == SqlKind.UPDATE) { |
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 wonder whether there are other statements that would need this.
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, at least MERGE suffers from the same issue.
Added the corresponding test and fix.
f29d170
to
5385399
Compare
5385399
to
c2a1434
Compare
Quality Gate passedIssues Measures |
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
Show resolved
Hide resolved
@mihaibudiu, @caicancai, If the patch needs to be improved, then feel free to remove it from the current scope (1.38.0), so that it doesn't delay the release. |
@xtern Hi. You mean that it can only be recognized as a constant in the physical stage? It feels strange. |
In my previous message I mixed up the Let's turn it off and see the difference in plan tree in existing test Without this fix the plan is:
Note that But after applying this patch the plan is:
Note that
and this looks like an issue that needs to be fixed before merging this PR 😔 |
Validation currently fails with an AssertionError on an UPDATE query with a sub-query that requires an implicit type cast. (See CALCITE-6570 for details).
Example
During validation, when registering subqueries, Calcite wraps the sub-query in a SCALAR_QUERY call in
selectList
(sqlUpdate.getSourceSelect().getSelectList()
).But after that,
TypeCoersion
tries to coerce types for expressions insourceExpressionList
(seeTypeCoersionImpl.coerceSourceRowType()
), but it containsSqlSelect
instead ofSCALAR_QUERY
call.As a solution I added
SCALAR_QUERY
tosourceExpressionList
as well.