You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ch...@apache.org on 2022/06/20 02:22:48 UTC
[calcite] branch main updated (bbdef53899 -> fa65a2ec46)
This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
discard bbdef53899 Enable sort by alias for BigQuery
new fa65a2ec46 [CALCITE-5191] Allow sort by alias in BigQuery
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (bbdef53899)
\
N -- N -- N refs/heads/main (fa65a2ec46)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[calcite] 01/01: [CALCITE-5191] Allow sort by alias in BigQuery
Posted by ch...@apache.org.
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
commit fa65a2ec460abcd574e7f28672478a0510da65a1
Author: wenrui <we...@singleorigin.tech>
AuthorDate: Tue Jun 14 14:50:49 2022 -0700
[CALCITE-5191] Allow sort by alias in 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")