You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2023/06/08 21:21:29 UTC

[calcite] branch main updated (8a5cf837d1 -> cf7f71bcde)

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

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


 discard 8a5cf837d1 lint
 discard ebf8cb2940 oops, forgot test
 discard 8ea4160f10 [CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are equal under `compareTo` but not `equals`
    omit c14e071590 [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)
    omit 295df907d1  [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort with offset
     add e34caf70ac [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort with offset
     add 671f49d7d0 [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)
     add 6ffcb86052 [CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are equal under `compareTo` but not `equals`
     add bfa7d782b1 [CALCITE-4555] Invalid zero literal value is used for TIMESTAMP WITH LOCAL TIME ZONE type in RexBuilder
     add 462f8c3b7d [CALCITE-5746] Support JDK 19
     add baa6b104f3 [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark library)
     add 967bb5acc5 [CALCITE-5676] In JDBC DatabaseMetaData.getColumns, set DATA_TYPE and TYPE_NAME metadata values for MEASURE types
     add 2cb766380a [CALCITE-5738] Add SORT_ARRAY function (enabled in Spark library)
     add 821f03be6a [CALCITE-5704] Add ARRAY_EXCEPT, ARRAY_INTERSECT, ARRAY_UNION function (enabled in Spark library)
     new cf7f71bcde [CALCITE-5768] JDBC adapter should insert a subquery for a query with ORDER BY ordinal

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   (8a5cf837d1)
            \
             N -- N -- N   refs/heads/main (cf7f71bcde)

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:
 .github/workflows/main.yml                         |  16 +--
 .../calcite/adapter/enumerable/RexImpTable.java    |  36 ++++-
 .../org/apache/calcite/jdbc/CalciteMetaImpl.java   |  11 +-
 .../apache/calcite/prepare/CalcitePrepareImpl.java |  14 +-
 .../apache/calcite/rel/rel2sql/SqlImplementor.java |  12 +-
 .../org/apache/calcite/rel/type/RelDataType.java   |   9 ++
 .../java/org/apache/calcite/rex/RexBuilder.java    |   2 +-
 .../apache/calcite/runtime/CalciteResource.java    |   3 +
 .../org/apache/calcite/runtime/SqlFunctions.java   |  59 +++++++++
 .../main/java/org/apache/calcite/sql/SqlKind.java  |  21 +++
 .../calcite/sql/fun/SqlLibraryOperators.java       |  72 ++++++++--
 .../apache/calcite/sql/parser/SqlParserUtil.java   |  20 +--
 .../apache/calcite/sql/type/MeasureSqlType.java    |   4 +
 .../org/apache/calcite/sql/type/OperandTypes.java  |  65 +++++++++
 .../org/apache/calcite/sql/type/ReturnTypes.java   |  17 ++-
 .../apache/calcite/sql/type/SqlTypeTransforms.java |   5 +-
 .../org/apache/calcite/util/BuiltInMethod.java     |   6 +
 .../main/java/org/apache/calcite/util/Util.java    |  18 +--
 .../calcite/runtime/CalciteResource.properties     |   1 +
 .../calcite/jdbc/CalciteRemoteDriverTest.java      |  43 +++++-
 .../calcite/rel/rel2sql/RelToSqlConverterTest.java |  18 +++
 .../org/apache/calcite/rex/RexBuilderTest.java     |  70 ++++++++++
 .../apache/calcite/test/JdbcFrontLinqBackTest.java |  53 ++++++--
 .../java/org/apache/calcite/test/JdbcTest.java     |   2 +-
 .../java/org/apache/calcite/util/UtilTest.java     |   2 +-
 gradle.properties                                  |   4 +-
 site/_docs/history.md                              |   9 +-
 site/_docs/howto.md                                |   6 +-
 site/_docs/reference.md                            |   8 +-
 src/main/config/forbidden-apis/signatures.txt      |   5 +
 .../apache/calcite/sql/test/AbstractSqlTester.java |   2 +-
 .../org/apache/calcite/test/SqlOperatorTest.java   | 146 +++++++++++++++++++--
 .../apache/calcite/testlib/WithLocaleExtension.kt  |   6 +-
 33 files changed, 672 insertions(+), 93 deletions(-)


[calcite] 01/01: [CALCITE-5768] JDBC adapter should insert a subquery for a query with ORDER BY ordinal

Posted by jh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cf7f71bcde345cdb814f01adb8eb7d0f11e8e83f
Author: Will Noble <wn...@google.com>
AuthorDate: Wed Jun 7 18:16:59 2023 -0700

    [CALCITE-5768] JDBC adapter should insert a subquery for a query with ORDER BY ordinal
    
    The incorrect query has an ordinal that is not the first item
    of the ORDER BY clause:
    
      SELECT "JOB"
      FROM "scott"."EMP"
      GROUP BY "JOB"
      ORDER BY "JOB", 2
    
    The correct query should have a subquery:
    
      SELECT "JOB"
      FROM (SELECT "JOB", COUNT("ENAME") AS "$f1"
        FROM "scott"."EMP"
        GROUP BY "JOB"
        ORDER BY "JOB", 2) AS "t0"
---
 .../org/apache/calcite/rel/rel2sql/SqlImplementor.java | 12 +++++++-----
 .../calcite/rel/rel2sql/RelToSqlConverterTest.java     | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java b/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
index f04a5a11cf..e90e5dacbc 100644
--- a/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
+++ b/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
@@ -1898,12 +1898,14 @@ public abstract class SqlImplementor {
           return false;
         }
         for (SqlNode sqlNode : orderList) {
-          if (!(sqlNode instanceof SqlBasicCall)) {
-            return sqlNode instanceof SqlNumericLiteral;
+          if (sqlNode instanceof SqlNumericLiteral) {
+            return true;
           }
-          for (SqlNode operand : ((SqlBasicCall) sqlNode).getOperandList()) {
-            if (operand instanceof SqlNumericLiteral) {
-              return true;
+          if (sqlNode instanceof SqlBasicCall) {
+            for (SqlNode operand : ((SqlBasicCall) sqlNode).getOperandList()) {
+              if (operand instanceof SqlNumericLiteral) {
+                return true;
+              }
             }
           }
         }
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 412ddb4c16..9de19094a8 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -400,6 +400,24 @@ class RelToSqlConverterTest {
     relFn(relFn).ok(expected);
   }
 
+  @Test void testUsesSubqueryWhenSortingByIdThenOrdinal() {
+    final Function<RelBuilder, RelNode> relFn = b -> b
+        .scan("EMP")
+        .aggregate(
+            b.groupKey("JOB"),
+            b.aggregateCall(SqlStdOperatorTable.COUNT, b.field("ENAME")))
+        .sort(b.field(0), b.field(1))
+        .project(b.field(0))
+        .build();
+    final String expected = "SELECT \"JOB\"\n"
+        + "FROM (SELECT \"JOB\", COUNT(\"ENAME\") AS \"$f1\"\n"
+        + "FROM \"scott\".\"EMP\"\n"
+        + "GROUP BY \"JOB\"\n"
+        + "ORDER BY \"JOB\", 2) AS \"t0\"";
+
+    relFn(relFn).ok(expected);
+  }
+
   @Test void testSelectQueryWithWhereClauseOfBasicOperators() {
     String query = "select * from \"product\" "
         + "where (\"product_id\" = 10 OR \"product_id\" <= 5) "