You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by li...@apache.org on 2022/11/16 01:13:47 UTC

[calcite] branch main updated (28c5881c8d -> a0ce327511)

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

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


    omit 28c5881c8d [CALCITE-5310] JSON_OBJECT in scalar sub-query throws AssertionError
    omit 1c55ab0892 [CALCITE-5383] Add CONCAT to BIG_QUERY dialect
     new 12e9ad4550 [CALCITE-5383] Add CONCAT to BIG_QUERY dialect
     new a0ce327511 [CALCITE-5310] JSON_OBJECT in scalar sub-query throws AssertionError

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   (28c5881c8d)
            \
             N -- N -- N   refs/heads/main (a0ce327511)

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 2 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:
 site/_docs/reference.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[calcite] 02/02: [CALCITE-5310] JSON_OBJECT in scalar sub-query throws AssertionError

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

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

commit a0ce3275119f804959cda54d6e7a016ab893c359
Author: Benchao Li <li...@gmail.com>
AuthorDate: Thu Oct 6 15:43:51 2022 +0800

    [CALCITE-5310] JSON_OBJECT in scalar sub-query throws AssertionError
    
    Close #2929
---
 core/src/main/java/org/apache/calcite/rex/RexUtil.java     | 14 ++++++++++++++
 .../org/apache/calcite/sql/type/SqlTypeAssignmentRule.java |  3 +++
 .../java/org/apache/calcite/sql2rel/RelDecorrelator.java   |  5 +++--
 core/src/test/resources/sql/sub-query.iq                   | 14 ++++++++++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index d5b4bc3cc7..b68eb43831 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -209,6 +209,20 @@ public class RexUtil {
     }
   }
 
+  /**
+   * Returns whether a node represents a {@link SqlTypeName#SYMBOL} literal.
+   */
+  public static boolean isSymbolLiteral(RexNode expr) {
+    switch (expr.getKind()) {
+    case LITERAL:
+      return ((RexLiteral) expr).getTypeName() == SqlTypeName.SYMBOL;
+    case CAST:
+      return isSymbolLiteral(((RexCall) expr).operands.get(0));
+    default:
+      return false;
+    }
+  }
+
   /**
    * Returns whether a node represents a literal.
    *
diff --git a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java
index 41791da14f..6504814355 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeAssignmentRule.java
@@ -193,6 +193,9 @@ public class SqlTypeAssignmentRule implements SqlTypeMappingRule {
     // MAP is assignable from ...
     rules.add(SqlTypeName.MAP, EnumSet.of(SqlTypeName.MAP));
 
+    // SYMBOL is assignable from ...
+    rules.add(SqlTypeName.SYMBOL, EnumSet.of(SqlTypeName.SYMBOL));
+
     // ANY is assignable from ...
     rule.clear();
     rule.add(SqlTypeName.TINYINT);
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index 1786ffcaa1..7e7f2036ad 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -1790,10 +1790,11 @@ public class RelDecorrelator implements ReflectiveVisitor {
 
     @Override public RexNode visitLiteral(RexLiteral literal) {
       // Use nullIndicator to decide whether to project null.
-      // Do nothing if the literal is null.
+      // Do nothing if the literal is null or symbol.
       if (!RexUtil.isNull(literal)
           && projectPulledAboveLeftCorrelator
-          && (nullIndicator != null)) {
+          && (nullIndicator != null)
+          && !RexUtil.isSymbolLiteral(literal)) {
         return createCaseExpression(nullIndicator, null, literal);
       }
       return literal;
diff --git a/core/src/test/resources/sql/sub-query.iq b/core/src/test/resources/sql/sub-query.iq
index a22ee003f9..e464dba2e5 100644
--- a/core/src/test/resources/sql/sub-query.iq
+++ b/core/src/test/resources/sql/sub-query.iq
@@ -3569,4 +3569,18 @@ SELECT ARRAY(SELECT s.x) FROM (SELECT 1 as x) s;
 
 !ok
 
+# Test case for [CALCITE-5310] JSON_OBJECT in scalar sub-query throws AssertionError
+SELECT (SELECT json_object('1': (a.attidentity = 'a'), '2': v) FROM UNNEST(ARRAY[1]) as v) as options
+FROM UNNEST(ARRAY['a', 'b']) AS a(attidentity);
+
++-------------------+
+| OPTIONS           |
++-------------------+
+| {"1":false,"2":1} |
+| {"1":true,"2":1}  |
++-------------------+
+(2 rows)
+
+!ok
+
 # End sub-query.iq


[calcite] 01/02: [CALCITE-5383] Add CONCAT to BIG_QUERY dialect

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

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

commit 12e9ad4550caf3482b33895d2067ba50177bb8ba
Author: Oliver Lee <ol...@google.com>
AuthorDate: Fri Nov 11 18:19:36 2022 +0000

    [CALCITE-5383] Add CONCAT to BIG_QUERY dialect
    
    Close #2970
---
 core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java | 2 +-
 site/_docs/reference.md                                                | 2 +-
 testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java     | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
index 306a33b39f..1cde5d140f 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
@@ -539,7 +539,7 @@ public abstract class SqlLibraryOperators {
 
   /** The "CONCAT(arg, ...)" function that concatenates strings.
    * For example, "CONCAT('a', 'bc', 'd')" returns "abcd". */
-  @LibraryOperator(libraries = {MYSQL, POSTGRESQL})
+  @LibraryOperator(libraries = {MYSQL, POSTGRESQL, BIG_QUERY})
   public static final SqlFunction CONCAT_FUNCTION =
       new SqlFunction("CONCAT",
           SqlKind.OTHER_FUNCTION,
diff --git a/site/_docs/reference.md b/site/_docs/reference.md
index 15abb9b23b..ddf4698ccb 100644
--- a/site/_docs/reference.md
+++ b/site/_docs/reference.md
@@ -2584,7 +2584,7 @@ semantics.
 | o p | CHR(integer)                                 | Returns the character whose UTF-8 code is *integer*
 | o | COSH(numeric)                                  | Returns the hyperbolic cosine of *numeric*
 | o | CONCAT(string, string)                         | Concatenates two strings
-| m p | CONCAT(string [, string ]*)                  | Concatenates two or more strings
+| b m p | CONCAT(string [, string ]*)                | Concatenates two or more strings
 | m | COMPRESS(string)                               | Compresses a string using zlib compression and returns the result as a binary string.
 | p | CONVERT_TIMEZONE(tz1, tz2, datetime)           | Converts the timezone of *datetime* from *tz1* to *tz2*
 | b | CURRENT_DATETIME([timezone])                   | Returns the current time as a TIMESTAMP from *timezone*
diff --git a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
index 9d011d7d50..70861df1c5 100644
--- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
+++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
@@ -1834,6 +1834,7 @@ public class SqlOperatorTest {
     final SqlOperatorFixture f = fixture();
     checkConcatFunc(f.withLibrary(SqlLibrary.MYSQL));
     checkConcatFunc(f.withLibrary(SqlLibrary.POSTGRESQL));
+    checkConcatFunc(f.withLibrary(SqlLibrary.BIG_QUERY));
     checkConcat2Func(f.withLibrary(SqlLibrary.ORACLE));
   }