barrkel commented on code in PR #3336:
URL: https://github.com/apache/calcite/pull/3336#discussion_r1537365076


##########
core/src/main/java/org/apache/calcite/sql/SqlOperator.java:
##########
@@ -537,6 +538,11 @@ public RelDataType inferReturnType(
             + opBinding.collectOperandTypes());
       }
 
+      // MEASURE wrapper should be removed, e.g. MEASURE<DOUBLE> should just 
be DOUBLE
+      if (isMeasure(returnType) && returnType.getMeasureElementType() != null) 
{
+        returnType = 
Objects.requireNonNull(returnType.getMeasureElementType());

Review Comment:
   I am leaving this comment to highlight relevant code to ask @tanclary about 
it.
   
   This strips off the `MEASURE<>`-ness from `SELECT`ed columns when the `AS` 
operator is used - aliases are modeled in the AST as an operator.
   
   This means that if
   
   ```
   SELECT m FROM table
   ```
   
   has `m` of type `MEASURE<INTEGER>`, then
   
   ```
   SELECT m AS m FROM table
   ```
   
   will have `m` of type `INTEGER`. This then causes breakage when the AST 
validator has a different opinion about the type of the row than the conversion 
into rel nodes.
   
   I want to understand more about the requirement to strip off `MEASURE`. I 
think it shouldn't be done for `AS`, but if I can understand why it does need 
to be done, then there might be more cases where it shouldn't be done.



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to