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

Zhen Chen edited comment on CALCITE-7331 at 12/14/25 1:17 PM:
--------------------------------------------------------------

[~julianhyde] Thank you so much for your detailed and comprehensive questions. 
These things should indeed have been done sooner, which would have saved you a 
lot of time. I apologize for that. I have provided answers to each question, 
although these might actually be in CALCITE-7310, but since you replied here, 
I've answered them in this Jira. Please check if this meets your needs.
{quote}You should link to the case where we added EXCLUDE.
{quote}
I have linked the CALCITE-7310
{quote}Include at least one example.
{quote}
In CALCITE-7310 , We can support following:

 
{code:java}
SELECT * EXCLUDE(deptno, empno) FROM emp; // ok
SELECT * EXCLUDE(deptno, empno, empno) FROM emp; // ok, empno will be 
deduplicated
SELECT emp.* EXCLUDE(emp.deptno, emp.empno) FROM emp; // ok, support sql 
identifier
SELECT * EXCLUDE(deptno, foo) FROM emp; // failed
SELECT * EXCLUDE(deptno, dname, loc) FROM dept; // failed, empty select list
{code}
 
{quote}Clickhouse supports "SELECT expr EXCEPT ()", not just "SELECT * EXCEPT". 
The description should say exactly what we support.
{quote}
Similar to the implementation in ClickHouse, but the expr in <expr> 
EXCEPT(col1, col2) only supports *.
{quote}Is the syntax ambiguous? "SELECT 1 AS x, 2 AS y EXCEPT (x)" is very 
similar to "SELECT 1 AS x, 2 AS y EXCEPT (SELECT 1, 3)"
{quote}
To avoid confusion, EXCLUDE only supports columns and does not support SELECT 
clauses.
{quote}Which config option(s) control this? Is it enabled by default?
{quote}
Since this syntax is not in the SQL specification, it is only enabled in Babel 
and disabled in Core. This feature can be enabled using *includeStarExclude: 
true* (in the config.fmpp file).
{quote}Do you give an error if EXCEPT references columns that don't exist?
{quote}
Yes, see the example above please.
{quote}Do you give an error if EXCEPT has duplicates?
{quote}
No, It will automatically remove duplicates.
{quote}Do you give an error if, after applying EXCEPT, there are zero columns?
{quote}
Yes, it will throw an error.


was (Author: jensen):
[~julianhyde] Thank you so much for your detailed and comprehensive questions. 
These things should indeed have been done sooner, which would have saved you a 
lot of time. I apologize for that. I have provided answers to each question, 
although these might actually be in CALCITE-7310, but since you replied here, 
I've answered them in this Jira. Please check if this meets your needs.
{quote}You should link to the case where we added EXCLUDE.
{quote}
I have linked the CALCITE-7310
{quote}Include at least one example.
{quote}
In CALCITE-7310 , We can support following:

 
{code:java}
SELECT * EXCLUDE(deptno, empno) FROM emp; // ok
SELECT * EXCLUDE(deptno, empno, empno) FROM emp; // ok, empno will be 
deduplicated
SELECT emp.* EXCLUDE(emp.deptno, emp.empno) FROM emp; // ok, support sql 
identifier
SELECT * EXCLUDE(deptno, foo) FROM emp; // failed{code}
 
{quote}Clickhouse supports "SELECT expr EXCEPT ()", not just "SELECT * EXCEPT". 
The description should say exactly what we support.
{quote}
Similar to the implementation in ClickHouse, but the expr in <expr> 
EXCEPT(col1, col2) only supports *.
{quote}Is the syntax ambiguous? "SELECT 1 AS x, 2 AS y EXCEPT (x)" is very 
similar to "SELECT 1 AS x, 2 AS y EXCEPT (SELECT 1, 3)"
{quote}
To avoid confusion, EXCLUDE only supports columns and does not support SELECT 
clauses.
{quote}Which config option(s) control this? Is it enabled by default?
{quote}
Since this syntax is not in the SQL specification, it is only enabled in Babel 
and disabled in Core. This feature can be enabled using *includeStarExclude: 
true* (in the config.fmpp file).
{quote}Do you give an error if EXCEPT references columns that don't exist?
{quote}
Yes, see the example above please.
{quote}Do you give an error if EXCEPT has duplicates?
{quote}
No, It will automatically remove duplicates.
{quote}Do you give an error if, after applying EXCEPT, there are zero columns?
{quote}
Yes, it will throw an error.

> Support the alias form SELECT * EXCEPT() for SELECT * EXCLUDE()
> ---------------------------------------------------------------
>
>                 Key: CALCITE-7331
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7331
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Zhen Chen
>            Assignee: Zhen Chen
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.42.0
>
>
> Based on the CALCITE-7310 implementation, this Jira primarily serves as an 
> alias extension. For example:
> SELECT * EXCLUDE(deptno, empno) FROM emp;
> Similarly, it can be written as:
> SELECT * EXCEPT(deptno, empno) FROM emp;
> Similar to the implementation in ClickHouse[1], but the expr in <expr> 
> EXCEPT(col1, col2) only supports *.
> [1] 
> [https://clickhouse.com/docs/zh/sql-reference/statements/select/except-modifier]



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

Reply via email to