You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Nick Riasanovsky <ni...@bodo.ai> on 2022/11/28 20:44:48 UTC

Using aliases later in a projection

Hello Calcite developers,

I'm working on a project using Calcite and I'm looking to support certain
SQL queries that are supported by Snowflake. Snowflake allows using
references in the same SELECT statement in which they are created, such as:

select 1 as X, X + 2

My understanding is that most SQL engines will not allow this so reasonably
this is not supported by default in Calcite. However, I was wondering if
there is any existing configuration that currently supports this or if
anyone can give me some advice on how to support this.

Thanks,
Nick Riasanovsky

Re: Using aliases later in a projection

Posted by Jay Narale <ja...@gmail.com>.
Hi Nick,
   I had created a ticket for this and other types of column aliasing in
https://issues.apache.org/jira/browse/CALCITE-5248 and compiled edge cases
<https://docs.google.com/document/d/1bt_5CmRg97gh_j_lsVrnoEDn5N3TRNGeYcyX4uGD_0g/edit>
based
on Teradata's behavior.
If you browse the comments, the ticket also has an unfinished patch with
some remaining work in adding feature flags + tests + improvements
like pushing common expressions below the project and maybe we could add
snowflake's behavior too for comparison and a snowflake-specific feature
flag.

On Mon, Nov 28, 2022 at 12:45 PM Nick Riasanovsky <ni...@bodo.ai> wrote:

> Hello Calcite developers,
>
> I'm working on a project using Calcite and I'm looking to support certain
> SQL queries that are supported by Snowflake. Snowflake allows using
> references in the same SELECT statement in which they are created, such as:
>
> select 1 as X, X + 2
>
> My understanding is that most SQL engines will not allow this so reasonably
> this is not supported by default in Calcite. However, I was wondering if
> there is any existing configuration that currently supports this or if
> anyone can give me some advice on how to support this.
>
> Thanks,
> Nick Riasanovsky
>


-- 
Warm Regards,

Jay Narale