[ 
https://issues.apache.org/jira/browse/CALCITE-6343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831408#comment-17831408
 ] 

Barry Kelly commented on CALCITE-6343:
--------------------------------------

I'll give a stab at adding another test and I'm willing to update documentation.

For Looker, we're supporting naked measures mostly so that an exploratory 
{{SELECT *}} and its expanded equivalent doesn't blow up. We're relying on 
{{AGGREGATE()}} to convert it into a value; without using {{AGGREGATE}}, in a 
non-aggregate query, naked measures evaluate to null. Computation over them, 
and thus conversion of the type of expressions using them, isn't expected to be 
useful.

This specific change is as far as I can tell simply a bug (an inconsistency) in 
Calcite. An AST as simple as {{SELECT m AS m FROM t}} where {{m}} is a measure 
cannot go through {{SqlToRel}} conversion because the row type of the rel tree 
is different to the type inferred from the AST, and it blows up with an 
[assertion 
error|https://github.com/apache/calcite/blob/d5b6b5c01ff17cac100a591a4cc4c9e83d4e1ace/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java#L503].

> AS alias operator strips MEASUREness from measures
> --------------------------------------------------
>
>                 Key: CALCITE-6343
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6343
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Barry Kelly
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.37.0
>
>
> CALCITE-5869 introduced a change which removes MEASURE when inferring the 
> return type when an operator is applied.
> The {{AS}} keyword for aliases is implemented as an operator in the SQL AST. 
> Using {{AS}} removes MEASURE when typing expressions that have an alias in 
> the {{SELECT}} clause.
> Thus, the type of {{SELECT m}} and {{SELECT m AS m}} are different when {{m}} 
> is a measure. This is not desirable.
> Proposed fix: don't change type when using the {{AS}} operator.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to