hannerwang commented on code in PR #2838:
URL: https://github.com/apache/calcite/pull/2838#discussion_r903611021


##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -6661,6 +6661,11 @@ static class ExtendedExpander extends Expander {
           SqlIdentifier sid = (SqlIdentifier) expr;
           final SqlIdentifier fqId = getScope().fullyQualify(sid).identifier;
           expr = expandDynamicStar(sid, fqId);
+        } else {
+          requireNonNull(expr, "expr");
+          SqlNode exprCopy = expr.clone(expr.getParserPosition());

Review Comment:
   Look the new test case, before the commit,  the **X** alias in CUBE will be 
expanded to 'empno / 2' expression without copy, so the 'empno / 2' in SELECT 
LIST and CUBE is same,  being type of **Integer not null**. 
   When calcite derive the select item 'empno / 2 AS x', the type of 'empno / 
2' will be **reused**, so the 'empno / 2 AS x' will be also **Integer not 
null**, this is not consistent with CUBE operator, GROUPING SETS () will make 
'empno / 2 AS x' nullable. 
   I make a copy in GROUP expression to make sure the 'empno / 2' type couldn't 
be **reused** and  the type of 'empno / 2' in SELECT LIST could be derive in 
correct AggregatingSelectScope.



-- 
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]

Reply via email to