zachjsh commented on code in PR #15962:
URL: https://github.com/apache/druid/pull/15962#discussion_r1525308508
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java:
##########
@@ -226,6 +235,20 @@ public void validateInsert(final SqlInsert insert)
// Determine the output (target) schema.
final RelDataType targetType = validateTargetType(scope, insertNs, insert,
sourceType, tableMetadata);
+ // WITH node type is computed to be the type of the body recursively in
+ // org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery}. If this
computed type
+ // is different than the type validated and stored for the node in memory
a nasty relational
+ // algebra error will occur in
org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType.
+ // During the validateTargetType call above, the WITH body node validated
type may be updated
+ // with any coercions applied. We update the validated node type of the
WITH node here so
+ // that they are consistent.
+ if (source instanceof SqlWith) {
+ final RelDataType withBodyType = getValidatedNodeTypeIfKnown(((SqlWith)
source).body);
Review Comment:
It seems that this goes beyond null handling; implicitly coerced types
coming from calcite's default enabled coercion rules, do not seem to be updated
in the WITH node type, only the WITH select body node type. This would still be
needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]