You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Jay Narale (Jira)" <ji...@apache.org> on 2022/08/26 18:06:00 UTC

[jira] [Created] (CALCITE-5248) Support Column Aliasing feature in the where clause

Jay Narale created CALCITE-5248:
-----------------------------------

             Summary: Support Column Aliasing feature in the where clause
                 Key: CALCITE-5248
                 URL: https://issues.apache.org/jira/browse/CALCITE-5248
             Project: Calcite
          Issue Type: New Feature
            Reporter: Jay Narale


Based on the discussion [https://lists.apache.org/thread/7zk5wqgsk64903w5mbt72pwjmsftx0kz].

The goal is to support column aliasing. An example is Teradata / [https://docs.teradata.com/r/Teradata-Database-SQL-Fundamentals/June-2017/Basic-SQL-Syntax/Referencing-Object-Names-in-a-Request/Using-a-Column-Alias] 

 

A few edge cases to be considered for proper semantics

1. When SubQuery( maybe table) in from and Alias have the same name

eg 

 SELECT  c_customerId as c FROM ( SELECT c FROM table) WHERE c = 'test' 

 SELECT  trim(c_customer_name) as c FROM ( SELECT c FROM table) WHERE c = 'test' 

Comments 

In a database, the execution order is FROM > WHERE > SELECT so the semantics should be that column in the subquery is given priority and a filter is  applied to that column

Behavior in Teradata

Consistent with the above, a Filter is applied to the SubQuery

 

2. When a correlated column outside the query has the same name as the alias

TBD

      Here I think the behavior should be identical to the behavior in OrderBy



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