NobiGo commented on code in PR #4289:
URL: https://github.com/apache/calcite/pull/4289#discussion_r2032687930
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlConformance.java:
##########
@@ -102,6 +102,16 @@ public interface SqlConformance {
*/
boolean isGroupByAlias();
+ /**
+ * Whether to allow aliases from the {@code SELECT} clause to be used as
+ * column names in the same {@code SELECT} clause.
+ * E.g., SELECT 1 as X, X+1 as Y;
+ * Name lookup considers an identifier in the same SELECT only
+ * if other lookups failed.
+ * Supported by Spark, Snowflake, BigQuery.
Review Comment:
Spark currently does not support.
##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -6677,6 +6677,32 @@ public boolean isBangEqualAllowed() {
.withConformance(lenient).fails("Column 'E' not found in any table");
}
+ /** Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-6939">
+ * [CALCITE-6939] Add support for Lateral Column Alias</a>. */
+ @Test void testAliasInSelect() {
+ final SqlConformance withSelectAlias = new SqlAbstractConformance() {
+ @Override public boolean isSelectAlias() {
+ return true;
+ }
+ };
+
+ // Standard conformance
+ sql("select 1 AS x, ^x^ as Y")
Review Comment:
1: Does this currently support SQL execution? Or is it only supporting
validate?
2: If the table includes x and y columns, what would the output be if it is
renamed as x?
Some cases I test in Spark:
```
create table table(x int,y int);
insert into table values(1, 2);
select 2 as x, x + 2 from table; // output=> 2 3
select 2 as x1, x1 + 2; // Error in query: cannot resolve '`x1`' given
input columns: []; line 1 pos **17;**
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]