This is an automated email from the ASF dual-hosted git repository.

chunwei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new bbdef53899 Enable sort by alias for BigQuery
bbdef53899 is described below

commit bbdef5389908121ee67ba3a7381266ab586f36bb
Author: wenrui <[email protected]>
AuthorDate: Tue Jun 14 14:50:49 2022 -0700

    Enable sort by alias for BigQuery
---
 .../apache/calcite/sql/validate/SqlConformanceEnum.java  |  1 +
 .../java/org/apache/calcite/test/SqlValidatorTest.java   | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java 
b/core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java
index 76786f4531..9b8d805d61 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java
@@ -171,6 +171,7 @@ public enum SqlConformanceEnum implements SqlConformance {
     case ORACLE_12:
     case STRICT_92:
     case SQL_SERVER_2008:
+    case BIG_QUERY:
       return true;
     default:
       return false;
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index b2f91e384f..2bd4709e60 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -78,6 +78,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.function.Consumer;
 
+import static org.apache.calcite.sql.validate.SqlConformanceEnum.BIG_QUERY;
 import static org.apache.calcite.test.Matchers.isCharset;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -369,7 +370,7 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   @Test void testNiladicForBigQuery() {
     sql("select current_time, current_time(), current_date, "
         + "current_date(), current_timestamp, current_timestamp()")
-        .withConformance(SqlConformanceEnum.BIG_QUERY).ok();
+        .withConformance(BIG_QUERY).ok();
   }
 
   @Test void testEqualNotEqual() {
@@ -1533,7 +1534,7 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
   @Test void testCurrentDatetime() throws SqlParseException, 
ValidationException {
     final String currentDateTimeExpr = "select ^current_datetime^";
     SqlValidatorFixture shouldFail = sql(currentDateTimeExpr)
-        .withConformance(SqlConformanceEnum.BIG_QUERY);
+        .withConformance(BIG_QUERY);
     final String expectedError = "query [select CURRENT_DATETIME]; exception "
         + "[Column 'CURRENT_DATETIME' not found in any table]; class "
         + "[class org.apache.calcite.sql.validate.SqlValidatorException]; pos 
[line 1 col 8 thru line 1 col 8]";
@@ -1541,13 +1542,13 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
 
     final SqlOperatorTable opTable = operatorTableFor(SqlLibrary.BIG_QUERY);
     sql("select current_datetime()")
-        .withConformance(SqlConformanceEnum.BIG_QUERY)
+        .withConformance(BIG_QUERY)
         .withOperatorTable(opTable).ok();
     sql("select CURRENT_DATETIME('America/Los_Angeles')")
-        .withConformance(SqlConformanceEnum.BIG_QUERY)
+        .withConformance(BIG_QUERY)
         .withOperatorTable(opTable).ok();
     sql("select CURRENT_DATETIME(CAST(NULL AS VARCHAR(20)))")
-        .withConformance(SqlConformanceEnum.BIG_QUERY)
+        .withConformance(BIG_QUERY)
         .withOperatorTable(opTable).ok();
   }
 
@@ -7354,6 +7355,11 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
     sql("select deptno as d, count(*) as c from emp group by deptno").ok();
   }
 
+  @Test void testSortByAliasColumnBigQuery() {
+    sql("select count(*) as total from emp order by 
total").withConformance(BIG_QUERY).ok();
+  }
+
+
   @Test void testNestedAggFails() {
     // simple case
     sql("select ^sum(max(empno))^ from emp")

Reply via email to