rongrong commented on code in PR #4439:
URL: https://github.com/apache/calcite/pull/4439#discussion_r2167256299
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -213,7 +214,11 @@ protected boolean coerceColumnType(
}
RelDataType targetType3 = syncAttributes(validator.deriveType(scope,
node), targetType);
SqlNode node3 = castTo(node, targetType3);
- if (node.getKind() == SqlKind.IDENTIFIER) {
+ // Although this function is called coerceColumnType, it is not always
invoked on a "column".
Review Comment:
I don't think this comment is accurate. What does "column" mean? In `CASE
WHEN x THEN x ELSE y END`, `x` and `y` are not different from `x` and `y` in
`SELECT x, y`. They are just names that refer to outputs you can find in the
child scope.
##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -213,7 +214,11 @@ protected boolean coerceColumnType(
}
RelDataType targetType3 = syncAttributes(validator.deriveType(scope,
node), targetType);
SqlNode node3 = castTo(node, targetType3);
- if (node.getKind() == SqlKind.IDENTIFIER) {
+ // Although this function is called coerceColumnType, it is not always
invoked on a "column".
+ // Preserve the original column name only if this expression is an item in
a select list.
+ boolean isSelectItem = (scope instanceof SelectScope)
Review Comment:
This should fix the issue. But it's a lot of logic to make things look nice
for a specific case, if you think it's really worth it.
--
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]