[calcite] 01/03: [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort with offset

2023-06-02 Thread jhyde
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 e34caf70ac97996035b8fd8fc494a64022b07f91
Author: guofeng.my 
AuthorDate: Thu Jun 1 17:06:50 2023 +0800

[CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort 
with offset
---
 .../test/enumerable/EnumerableLimitSortTest.java   | 172 +
 .../apache/calcite/linq4j/EnumerableDefaults.java  |   4 +-
 .../apache/calcite/linq4j/test/LimitSortTest.java  |  23 +--
 3 files changed, 187 insertions(+), 12 deletions(-)

diff --git 
a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
new file mode 100644
index 00..5c0d35ca4b
--- /dev/null
+++ 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test.enumerable;
+
+import org.apache.calcite.adapter.enumerable.EnumerableRules;
+import org.apache.calcite.adapter.java.ReflectiveSchema;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.test.CalciteAssert;
+import org.apache.calcite.test.schemata.hr.HrSchemaBig;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.function.Consumer;
+
+/** Tests for
+ * {@link org.apache.calcite.adapter.enumerable.EnumerableLimitSort}. */
+public class EnumerableLimitSortTest {
+
+  /** Test case for
+   * https://issues.apache.org/jira/browse/CALCITE-5730;>[CALCITE-5730]
+   * First nulls can be dropped by EnumerableLimitSort with offset. */
+  @Test void nullsFirstWithLimitAndOffset() {
+tester("select commission from emps order by commission nulls first limit 
1 offset 1 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[ASC-nulls-first], 
offset=[1], fetch=[1])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered("commission=null");
+  }
+
+  @Test void nullsLastWithLimitAndOffset() {
+tester("select commission from emps order by commission desc nulls last 
limit 8 offset 10 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[DESC-nulls-last], 
offset=[10], fetch=[8])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered(
+"commission=1000",
+"commission=1000",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500");
+  }
+
+  @Test void nullsFirstWithLimit() {
+tester("select commission from emps order by commission nulls first limit 
13 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[ASC-nulls-first], 
fetch=[13])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered(
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=250");
+  }
+
+  @Test void nullsLastWithLimit() {
+tester("select commission from emps order by commission nulls last limit 5 
")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[ASC], fetch=[5])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered(
+"commission=250",
+"commission=250",

[calcite] 02/03: [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)

2023-06-02 Thread jhyde
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 671f49d7d0ba09559a7d4977ebf250259a6fe526
Author: yongen.ly 
AuthorDate: Fri May 19 17:37:09 2023 +0800

[CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)
---
 .../calcite/adapter/enumerable/RexImpTable.java |  2 ++
 .../org/apache/calcite/runtime/SqlFunctions.java|  9 +
 .../main/java/org/apache/calcite/sql/SqlKind.java   |  3 +++
 .../apache/calcite/sql/fun/SqlLibraryOperators.java |  7 +++
 .../org/apache/calcite/sql/type/ReturnTypes.java| 21 +
 .../apache/calcite/sql/type/SqlTypeTransforms.java  | 11 +++
 .../org/apache/calcite/sql/type/SqlTypeUtil.java| 10 ++
 .../java/org/apache/calcite/util/BuiltInMethod.java |  1 +
 site/_docs/reference.md |  1 +
 .../org/apache/calcite/test/SqlOperatorTest.java| 14 ++
 10 files changed, 79 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 620926cf34..925bbec92e 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -172,6 +172,7 @@ import static 
org.apache.calcite.sql.fun.SqlLibraryOperators.LOG;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_AND;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_OR;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LPAD;
+import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_ENTRIES;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_KEYS;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_VALUES;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAX_BY;
@@ -693,6 +694,7 @@ public class RexImpTable {
   defineMethod(ARRAY_REPEAT, BuiltInMethod.ARRAY_REPEAT.method, 
NullPolicy.NONE);
   defineMethod(ARRAY_REVERSE, BuiltInMethod.ARRAY_REVERSE.method, 
NullPolicy.STRICT);
   defineMethod(ARRAY_SIZE, BuiltInMethod.COLLECTION_SIZE.method, 
NullPolicy.STRICT);
+  defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method, 
NullPolicy.STRICT);
   defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT);
   defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method, 
NullPolicy.STRICT);
   map.put(ARRAY_CONCAT, new ArrayConcatImplementor());
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java 
b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index e47a2d86f9..8c68768d1b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -3898,6 +3898,15 @@ public class SqlFunctions {
 return Collections.nCopies(numberOfElement, element);
   }
 
+  /** Support the MAP_ENTRIES function. */
+  public static List mapEntries(Map map) {
+final List result = new ArrayList(map.size());
+for (Map.Entry entry : map.entrySet()) {
+  result.add(Arrays.asList(entry.getKey(), entry.getValue()));
+}
+return result;
+  }
+
   /** Support the MAP_KEYS function. */
   public static List mapKeys(Map map) {
 return new ArrayList<>(map.keySet());
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlKind.java 
b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
index f8e10a41f4..b1f18b7136 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlKind.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
@@ -695,6 +695,9 @@ public enum SqlKind {
   /** {@code ARRAY_SIZE} function (Spark semantics). */
   ARRAY_SIZE,
 
+  /** {@code MAP_ENTRIES} function (Spark semantics). */
+  MAP_ENTRIES,
+
   /** {@code MAP_KEYS} function (Spark semantics). */
   MAP_KEYS,
 
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 476024dad5..bcc6e3fa1f 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
@@ -923,6 +923,13 @@ public abstract class SqlLibraryOperators {
   ReturnTypes.LEAST_RESTRICTIVE,
   OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
+  /** The "MAP_ENTRIES(map)" function. */
+  @LibraryOperator(libraries = {SPARK})
+  public static final SqlFunction MAP_ENTRIES =
+  SqlBasicFunction.create(SqlKind.MAP_ENTRIES,
+  ReturnTypes.TO_MAP_ENTRIES_NULLABLE,
+  OperandTypes.MAP);
+
   /** The "MAP_KEYS(map)" function. */
   @LibraryOperator(libraries = {SPARK})
   public static final SqlFunction MAP_KEYS =
diff --git 

[calcite] 03/03: [CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are equal under `compareTo` but not `equals`

2023-06-02 Thread jhyde
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 6ffcb860528e9025398b7b756fd4819fbe781e31
Author: ian.bertolacci 
AuthorDate: Wed May 24 12:49:40 2023 -0700

[CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are 
equal under `compareTo` but not `equals`

BigDecimal is a type that implements Comparable but whose
natural order is not consistent with equals. For example, if
x = BigDecimal("1.0") and and y = BigDecimal("1"),
x.equals(y) returns false and x.compareTo(y) returns 0.
Guava RangeSet is OK with such types, and Sarg should be also.

Before this fix, Sarg could not deduce that
  z < 1 or 1.0 < z
is equivalent to
  z <> 1

Close apache/calcite#3224
---
 .../java/org/apache/calcite/util/RangeSets.java|  10 +-
 .../org/apache/calcite/rex/RexProgramTest.java |  71 
 .../java/org/apache/calcite/util/RangeSetTest.java | 125 -
 .../java/org/apache/calcite/test/Matchers.java |  14 ++-
 4 files changed, 209 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/util/RangeSets.java 
b/core/src/main/java/org/apache/calcite/util/RangeSets.java
index a0967e2383..465ae83cc8 100644
--- a/core/src/main/java/org/apache/calcite/util/RangeSets.java
+++ b/core/src/main/java/org/apache/calcite/util/RangeSets.java
@@ -129,7 +129,7 @@ public class RangeSets {
   public static > boolean isPoint(Range range) {
 return range.hasLowerBound()
 && range.hasUpperBound()
-&& range.lowerEndpoint().equals(range.upperEndpoint())
+&& range.lowerEndpoint().compareTo(range.upperEndpoint()) == 0
 && !range.isEmpty();
   }
 
@@ -183,6 +183,10 @@ public class RangeSets {
 if (range.upperBoundType() == BoundType.OPEN) {
   return handler.closedOpen(lower, upper);
 } else {
+  // We use .equals rather than .compareTo, because if the endpoints
+  // are not equal the range could not have been created using
+  // Range.singleton. (If they are equal, we cannot distinguish
+  // between closed(v, v) but assume singleton(v).)
   if (lower.equals(upper)) {
 return handler.singleton(lower);
   } else {
@@ -249,6 +253,10 @@ public class RangeSets {
 if (range.upperBoundType() == BoundType.OPEN) {
   consumer.closedOpen(lower, upper);
 } else {
+  // We use .equals rather than .compareTo, because if the endpoints
+  // are not equal the range could not have been created using
+  // Range.singleton. (If they are equal, we cannot distinguish
+  // between closed(v, v) but assume singleton(v).)
   if (lower.equals(upper)) {
 consumer.singleton(lower);
   } else {
diff --git a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java 
b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
index e7663ba51f..8d695afbde 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.calcite.rex;
+
 import org.apache.calcite.avatica.util.ByteString;
 import org.apache.calcite.plan.RelOptPredicateList;
 import org.apache.calcite.plan.RelOptUtil;
@@ -1713,6 +1714,60 @@ class RexProgramTest extends RexProgramTestBase {
 .expandedSearch(expanded);
   }
 
+  @Test void testSimplifyRange8() {
+final RexNode aRef = input(tInt(true), 0);
+// a not in (1.0, 2.0)
+RexNode expr =
+not(
+in(aRef,
+literal(new BigDecimal("1.0")),
+literal(new BigDecimal("2.0";
+final String simplified = "SEARCH($0, "
++ "Sarg[(-\u221e..1.0:DECIMAL(2, 1)),"
++ " (1.0:DECIMAL(2, 1)..2.0:DECIMAL(2, 1)),"
++ " (2.0:DECIMAL(2, 1)..+\u221e)]:DECIMAL(2, 1))";
+checkSimplify(expr, simplified);
+
+// The following identical to previous, and simplifies to the same:
+//   a < 1.0 or (1.0 < a and a < 2.0) or 2.0 < a
+RexNode expr2 =
+or(lt(aRef, literal(new BigDecimal("1.0"))),
+and(lt(literal(new BigDecimal("1.0")), aRef),
+lt(aRef, literal(new BigDecimal("2.0",
+lt(literal(new BigDecimal("2.0")), aRef));
+checkSimplify(expr2, simplified);
+
+// Identical to previous, except one "2.0" is "2":
+//   a < 1.0 or (1.0 < a and a < 2.0) or 2.00 < a
+RexNode expr3 =
+or(lt(aRef, literal(new BigDecimal("1.0"))),
+and(lt(literal(new BigDecimal("1.0")), aRef),
+lt(aRef, literal(new BigDecimal("2.0",
+lt(literal(new BigDecimal("2")), aRef));
+final String simplified3 = "SEARCH($0, "
++ "Sarg[(-\u221e..1.0:DECIMAL(11, 1)),"
+  

[calcite] branch main updated (8ea4160f10 -> 6ffcb86052)

2023-06-02 Thread jhyde
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 8ea4160f10 [CALCITE-5722] Sarg.isComplementedPoints fails with 
anti-points which are equal under `compareTo` but not `equals`
 discard 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
 new e34caf70ac [CALCITE-5730] Initial null values can be dropped by 
EnumerableLimitSort with offset
 new 671f49d7d0 [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark 
library)
 new 6ffcb86052 [CALCITE-5722] Sarg.isComplementedPoints fails with 
anti-points which are equal under `compareTo` but not `equals`

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   (8ea4160f10)
\
 N -- N -- N   refs/heads/main (6ffcb86052)

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 3 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:
 .../java/org/apache/calcite/rex/RexProgramTest.java | 17 +
 1 file changed, 17 insertions(+)



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3054: (do not check in)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3054:
URL: https://github.com/apache/calcite/pull/3054#issuecomment-1574543473

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3054)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
   
   [![No Coverage 
information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png
 'No Coverage 
information')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=coverage=list)
 No Coverage information  
   [![No Duplication 
information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png
 'No Duplication 
information')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=duplicated_lines_density=list)
 No Duplication information
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] JiajunBernoulli commented on a diff in pull request #3202: [CALCITE-5704] Add ARRAY_EXCEPT, ARRAY_INTERSECT, ARRAY_UNION function (enabled in Spark library)

2023-06-02 Thread via GitHub


JiajunBernoulli commented on code in PR #3202:
URL: https://github.com/apache/calcite/pull/3202#discussion_r1215049429


##
site/_docs/reference.md:
##
@@ -2653,11 +2653,14 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | * | ACOSH(numeric) | Returns the inverse 
hyperbolic cosine of *numeric*
 | s | ARRAY(expr [, expr ]*) | Construct an array in 
Apache Spark
 | b | ARRAY_CONCAT(array [, array ]*)| Concatenates one or 
more arrays. If any input argument is `NULL` the function returns `NULL`
-| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements.
+| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements

Review Comment:
   `Returns unique elements that keep ordering of elements of *array*`



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] JiajunBernoulli commented on a diff in pull request #3202: [CALCITE-5704] Add ARRAY_EXCEPT, ARRAY_INTERSECT, ARRAY_UNION function (enabled in Spark library)

2023-06-02 Thread via GitHub


JiajunBernoulli commented on code in PR #3202:
URL: https://github.com/apache/calcite/pull/3202#discussion_r1215055311


##
site/_docs/reference.md:
##
@@ -2653,11 +2653,14 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | * | ACOSH(numeric) | Returns the inverse 
hyperbolic cosine of *numeric*
 | s | ARRAY(expr [, expr ]*) | Construct an array in 
Apache Spark
 | b | ARRAY_CONCAT(array [, array ]*)| Concatenates one or 
more arrays. If any input argument is `NULL` the function returns `NULL`
-| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements.
+| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements

Review Comment:
   Maybe `Removes duplicate values from the *array*`
   
   https://spark.apache.org/docs/latest/api/sql/#array_distinct



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] JiajunBernoulli commented on a diff in pull request #3202: [CALCITE-5704] Add ARRAY_EXCEPT, ARRAY_INTERSECT, ARRAY_UNION function (enabled in Spark library)

2023-06-02 Thread via GitHub


JiajunBernoulli commented on code in PR #3202:
URL: https://github.com/apache/calcite/pull/3202#discussion_r1215049429


##
site/_docs/reference.md:
##
@@ -2653,11 +2653,14 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | * | ACOSH(numeric) | Returns the inverse 
hyperbolic cosine of *numeric*
 | s | ARRAY(expr [, expr ]*) | Construct an array in 
Apache Spark
 | b | ARRAY_CONCAT(array [, array ]*)| Concatenates one or 
more arrays. If any input argument is `NULL` the function returns `NULL`
-| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements.
+| s | ARRAY_DISTINCT(array)  | Returns unique elements 
of *array*. Keeps ordering of elements

Review Comment:
   Returns unique elements that keep ordering of elements of *array*



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3054: (do not check in)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3054:
URL: https://github.com/apache/calcite/pull/3054#issuecomment-1574489818

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3054)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3054=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
   
   [![No Coverage 
information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png
 'No Coverage 
information')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=coverage=list)
 No Coverage information  
   [![No Duplication 
information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png
 'No Duplication 
information')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=duplicated_lines_density=list)
 No Duplication information
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] julianhyde commented on a diff in pull request #3206: [CALCITE-5724] Generated SQL uses literal values in ORDER BY clauses

2023-06-02 Thread via GitHub


julianhyde commented on code in PR #3206:
URL: https://github.com/apache/calcite/pull/3206#discussion_r1214942298


##
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##
@@ -1119,6 +1119,34 @@ public List fieldList() {
   };
 }
 
+/**
+ * Checks if a generated ORDER BY node is a literal value.
+ * @param node to check
+ * @return true if node is representing a literal value, false otherwise.
+ */
+boolean isLiteral(SqlNode node) {
+  // In dialects that use ordinals, NumericLiterals are ordinals and 
should be kept.
+  if (dialect.getConformance().isSortByOrdinal() && node instanceof 
SqlNumericLiteral) {
+return false;
+  }
+  if (node instanceof SqlLiteral) {
+return true;
+  } else {
+// The literal value may be wrapped in SqlBasicCalls applying postfix 
operators.
+while (node instanceof SqlBasicCall) {

Review Comment:
   testing for SqlBasicCall is too broad. `isLiteral('a' || x)` would currently 
return true, and that's wrong.
   
   I think you're only interested in stripping away DESC, NULLS FIRST, NULLS 
LAST. Is that true?
   
   If that is true, then you might do better checking for literal in the 
`RelFieldCollation` (i.e. before you call `toSql(field)`)



##
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##
@@ -1838,11 +1838,11 @@ private SqlDialect nonOrdinalDialect() {
   }
 
   /** Test case for
-   * https://issues.apache.org/jira/browse/CALCITE-5044;>[CALCITE-5044]
-   * JDBC adapter generates integer literal in ORDER BY, which some dialects
-   * wrongly interpret as a reference to a field. */

Review Comment:
   Maybe they can coexist. Add a method 
`SqlConformance.isSortByLiteralAllowed()`, default true, false in BigQuery. The 
test would have the old behavior if `isSortByLiteralAllowed` is true, the new 
behavior if it is false.



##
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##
@@ -1119,6 +1119,34 @@ public List fieldList() {
   };
 }
 
+/**
+ * Checks if a generated ORDER BY node is a literal value.
+ * @param node to check
+ * @return true if node is representing a literal value, false otherwise.
+ */
+boolean isLiteral(SqlNode node) {

Review Comment:
   method should be private, or name of method should indicate that tests 
whether a node is a literal for purposes of the ORDER BY clause



##
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##
@@ -1854,19 +1854,25 @@ private SqlDialect nonOrdinalDialect() {
 new RelFieldCollation(5, Direction.DESCENDING, 
NullDirection.LAST
 .project(b.field(2), b.field(1))
 .build();
-// Default dialect rewrite numeric constant keys to string literal in the 
order-by.
-// case1: numeric constant - rewrite it.
-// case2: string constant - no need rewrite it.
-// case3: wrap alias to numeric constant - rewrite it.
-// case4: wrap collation's info to numeric constant - rewrite it.
-relFn(relFn)
+final Function relFn2 = b -> b
+.scan("EMP")
+.project(b.literal(1), b.field(1), b.field(2), b.literal("23"),
+b.alias(b.literal(12), "col1"), b.literal(34))
+.sort(
+RelCollations.of(
+ImmutableList.of(
+new RelFieldCollation(0), new RelFieldCollation(3), new 
RelFieldCollation(4),
+new RelFieldCollation(5, Direction.DESCENDING, 
NullDirection.LAST
+.project(b.field(2), b.field(1))
+.build();
+relFn(relFn1)
 .ok("SELECT \"JOB\", \"ENAME\"\n"
 + "FROM \"scott\".\"EMP\"\n"
-+ "ORDER BY '1', '23', '12', \"ENAME\", '34' DESC NULLS LAST")
-.dialect(nonOrdinalDialect())
-.ok("SELECT JOB, ENAME\n"
-+ "FROM scott.EMP\n"
-+ "ORDER BY 1, '23', 12, ENAME, 34 DESC NULLS LAST");
++ "ORDER BY \"ENAME\"");
+relFn(relFn2)
+.ok("SELECT \"JOB\", \"ENAME\"\n"
++ "FROM \"scott\".\"EMP\"");
+
   }
 

Review Comment:
   add a test case where the ORDER BY clause has one literal, that literal is 
skipped by your code, and the generated query has no ORDER BY clause



##
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##
@@ -1838,11 +1838,11 @@ private SqlDialect nonOrdinalDialect() {
   }
 
   /** Test case for
-   * https://issues.apache.org/jira/browse/CALCITE-5044;>[CALCITE-5044]
-   * JDBC adapter generates integer literal in ORDER BY, which some dialects
-   * wrongly interpret as a reference to a field. */

Review Comment:
   You seem to have stomped on a unit test for CALCITE-5044. Does that mean 
that you think that the functionality added by CALCITE-5044 is wrong, and 
should be reverted? 
   
   If so, you should reference CALCITE-5044 

[calcite] branch main updated: [CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are equal under `compareTo` but not `equals`

2023-06-02 Thread jhyde
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


The following commit(s) were added to refs/heads/main by this push:
 new 8ea4160f10 [CALCITE-5722] Sarg.isComplementedPoints fails with 
anti-points which are equal under `compareTo` but not `equals`
8ea4160f10 is described below

commit 8ea4160f10e95aca6c3b0029d505bbc56975a873
Author: ian.bertolacci 
AuthorDate: Wed May 24 12:49:40 2023 -0700

[CALCITE-5722] Sarg.isComplementedPoints fails with anti-points which are 
equal under `compareTo` but not `equals`

BigDecimal is a type that implements Comparable but whose
natural order is not consistent with equals. For example, if
x = BigDecimal("1.0") and and y = BigDecimal("1"),
x.equals(y) returns false and x.compareTo(y) returns 0.
Guava RangeSet is OK with such types, and Sarg should be also.

Before this fix, Sarg could not deduce that
  z < 1 or 1.0 < z
is equivalent to
  z <> 1

Close apache/calcite#3224
---
 .../java/org/apache/calcite/util/RangeSets.java|  10 +-
 .../org/apache/calcite/rex/RexProgramTest.java |  54 +
 .../java/org/apache/calcite/util/RangeSetTest.java | 125 -
 .../java/org/apache/calcite/test/Matchers.java |  14 ++-
 4 files changed, 192 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/util/RangeSets.java 
b/core/src/main/java/org/apache/calcite/util/RangeSets.java
index a0967e2383..465ae83cc8 100644
--- a/core/src/main/java/org/apache/calcite/util/RangeSets.java
+++ b/core/src/main/java/org/apache/calcite/util/RangeSets.java
@@ -129,7 +129,7 @@ public class RangeSets {
   public static > boolean isPoint(Range range) {
 return range.hasLowerBound()
 && range.hasUpperBound()
-&& range.lowerEndpoint().equals(range.upperEndpoint())
+&& range.lowerEndpoint().compareTo(range.upperEndpoint()) == 0
 && !range.isEmpty();
   }
 
@@ -183,6 +183,10 @@ public class RangeSets {
 if (range.upperBoundType() == BoundType.OPEN) {
   return handler.closedOpen(lower, upper);
 } else {
+  // We use .equals rather than .compareTo, because if the endpoints
+  // are not equal the range could not have been created using
+  // Range.singleton. (If they are equal, we cannot distinguish
+  // between closed(v, v) but assume singleton(v).)
   if (lower.equals(upper)) {
 return handler.singleton(lower);
   } else {
@@ -249,6 +253,10 @@ public class RangeSets {
 if (range.upperBoundType() == BoundType.OPEN) {
   consumer.closedOpen(lower, upper);
 } else {
+  // We use .equals rather than .compareTo, because if the endpoints
+  // are not equal the range could not have been created using
+  // Range.singleton. (If they are equal, we cannot distinguish
+  // between closed(v, v) but assume singleton(v).)
   if (lower.equals(upper)) {
 consumer.singleton(lower);
   } else {
diff --git a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java 
b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
index e7663ba51f..1a356e75a9 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
@@ -1713,6 +1713,60 @@ class RexProgramTest extends RexProgramTestBase {
 .expandedSearch(expanded);
   }
 
+  @Test void testSimplifyRange8() {
+final RexNode aRef = input(tInt(true), 0);
+// a not in (1.0, 2.0)
+RexNode expr =
+not(
+in(aRef,
+literal(new BigDecimal("1.0")),
+literal(new BigDecimal("2.0";
+final String simplified = "SEARCH($0, "
++ "Sarg[(-\u221e..1.0:DECIMAL(2, 1)),"
++ " (1.0:DECIMAL(2, 1)..2.0:DECIMAL(2, 1)),"
++ " (2.0:DECIMAL(2, 1)..+\u221e)]:DECIMAL(2, 1))";
+checkSimplify(expr, simplified);
+
+// The following identical to previous, and simplifies to the same:
+//   a < 1.0 or (1.0 < a and a < 2.0) or 2.0 < a
+RexNode expr2 =
+or(lt(aRef, literal(new BigDecimal("1.0"))),
+and(lt(literal(new BigDecimal("1.0")), aRef),
+lt(aRef, literal(new BigDecimal("2.0",
+lt(literal(new BigDecimal("2.0")), aRef));
+checkSimplify(expr2, simplified);
+
+// Identical to previous, except one "2.0" is "2":
+//   a < 1.0 or (1.0 < a and a < 2.0) or 2.00 < a
+RexNode expr3 =
+or(lt(aRef, literal(new BigDecimal("1.0"))),
+and(lt(literal(new BigDecimal("1.0")), aRef),
+lt(aRef, literal(new BigDecimal("2.0",
+lt(literal(new BigDecimal("2")), aRef));
+final String simplified3 = "SEARCH($0, "
++ "Sarg[(-\u221e..1.0:DECIMAL(11, 1)),"
++ 

[GitHub] [calcite] asfgit closed pull request #3224: [CALCITE-5722] RangeSets.isPoint incorrectly gives false for closed ranges with endpoints which are equal under `.compareTo` but not under `.equals

2023-06-02 Thread via GitHub


asfgit closed pull request #3224: [CALCITE-5722] RangeSets.isPoint incorrectly 
gives false for closed ranges with endpoints which are equal under `.compareTo` 
but not under `.equals` 
URL: https://github.com/apache/calcite/pull/3224


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3206: [CALCITE-5724] Generated SQL uses literal values in ORDER BY clauses

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3206:
URL: https://github.com/apache/calcite/pull/3206#issuecomment-1574155161

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3206)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3206: [CALCITE-5724] Generated SQL uses literal values in ORDER BY clauses

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3206:
URL: https://github.com/apache/calcite/pull/3206#issuecomment-1574122568

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3206)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3206=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3206=false=CODE_SMELL)
   
   
[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png
 
'100.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3206=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs commented on pull request #3236: [CALCITE-5738] Add SORT_ARRAY function (enabled in Spark library)

2023-06-02 Thread via GitHub


liuyongvs commented on PR #3236:
URL: https://github.com/apache/calcite/pull/3236#issuecomment-1573906121

   fix conflicts with main branch and squash the commits


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3236: [CALCITE-5738] Add SORT_ARRAY function (enabled in Spark library)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3236:
URL: https://github.com/apache/calcite/pull/3236#issuecomment-1573898357

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3236)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3236=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3236=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3236=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=CODE_SMELL)
 [9 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3236=false=CODE_SMELL)
   
   
[![89.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'89.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3236=new_coverage=list)
 [89.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3236=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3236=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3236=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3238: [CALCITE-5744] Add STR_TO_MAP function (enabled in Spark library)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3238:
URL: https://github.com/apache/calcite/pull/3238#issuecomment-1573868243

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3238)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
 [14 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
   
   
[![95.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'95.1%')](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_coverage=list)
 [95.1% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] snuyanzin commented on pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


snuyanzin commented on PR #3113:
URL: https://github.com/apache/calcite/pull/3113#issuecomment-1573841516

   thanks a lot for having a look @zabetak , @rubenada 
   
   if there is no more objections/suggestions i'm going to merge this weekend


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] snuyanzin commented on a diff in pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


snuyanzin commented on code in PR #3113:
URL: https://github.com/apache/calcite/pull/3113#discussion_r1214460250


##
core/src/main/java/org/apache/calcite/util/Util.java:
##
@@ -1717,16 +1719,14 @@ private static void appendPosixTime(StringBuilder buf, 
int millis) {
* @return Java locale object
*/
   public static Locale parseLocale(String localeString) {
-String[] strings = localeString.split("_");
-switch (strings.length) {
-case 1:
-  return new Locale(strings[0]);
-case 2:
-  return new Locale(strings[0], strings[1]);
-case 3:
-  return new Locale(strings[0], strings[1], strings[2]);
-default:
-  throw new AssertionError("bad locale string '" + localeString + "'");
+if (localeString.isEmpty()) {
+  return Locale.ROOT;
+}
+try {
+  return new Locale.Builder().setLanguageTag(
+  UNDERSCORE.matcher(localeString).replaceAll("-")).build();
+} catch (IllformedLocaleException e) {
+  throw new AssertionError("bad locale string '" + localeString + "'", e);

Review Comment:
   makes sense, thanks



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3212: [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark li…

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3212:
URL: https://github.com/apache/calcite/pull/3212#issuecomment-1573801129

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3212)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
 [7 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
   
   
[![97.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'97.2%')](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_coverage=list)
 [97.2% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs commented on pull request #3212: [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark li…

2023-06-02 Thread via GitHub


liuyongvs commented on PR #3212:
URL: https://github.com/apache/calcite/pull/3212#issuecomment-1573782725

   @JiajunBernoulli  git rebase to fix conflicts with main branch


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs commented on a diff in pull request #3212: [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark li…

2023-06-02 Thread via GitHub


liuyongvs commented on code in PR #3212:
URL: https://github.com/apache/calcite/pull/3212#discussion_r1214409643


##
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##
@@ -500,7 +515,7 @@ public static SqlCall stripSeparator(SqlCall call) {
* Returns the element type of a MULTISET.
*/
   public static final SqlReturnTypeInference MULTISET_ELEMENT_NULLABLE =
-  MULTISET.andThen(SqlTypeTransforms.TO_MULTISET_ELEMENT_TYPE);
+  MULTISET.andThen(SqlTypeTransforms.TO_COLLECTION_ELEMENT_TYPE);

Review Comment:
   @JiajunBernoulli COLLECTION includes array and multiset, both have 
getComponentType, but doesn't include map type. map type has getKeyType and 
getValueType



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3113:
URL: https://github.com/apache/calcite/pull/3113#issuecomment-1573727509

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3113)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
   
   
[![72.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'72.7%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
 [72.7% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] JiajunBernoulli commented on a diff in pull request #3212: [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark li…

2023-06-02 Thread via GitHub


JiajunBernoulli commented on code in PR #3212:
URL: https://github.com/apache/calcite/pull/3212#discussion_r1214362380


##
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##
@@ -500,7 +515,7 @@ public static SqlCall stripSeparator(SqlCall call) {
* Returns the element type of a MULTISET.
*/
   public static final SqlReturnTypeInference MULTISET_ELEMENT_NULLABLE =
-  MULTISET.andThen(SqlTypeTransforms.TO_MULTISET_ELEMENT_TYPE);
+  MULTISET.andThen(SqlTypeTransforms.TO_COLLECTION_ELEMENT_TYPE);

Review Comment:
   `COLLECTION` usually also includes `MAP` and `SET`, does them also work?



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[calcite] branch main updated: [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)

2023-06-02 Thread jiajunxie
This is an automated email from the ASF dual-hosted git repository.

jiajunxie 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 c14e071590 [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark 
library)
c14e071590 is described below

commit c14e071590665a0ddda6c56cb95e2955fd8d5349
Author: yongen.ly 
AuthorDate: Fri May 19 17:37:09 2023 +0800

[CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)
---
 .../calcite/adapter/enumerable/RexImpTable.java |  2 ++
 .../org/apache/calcite/runtime/SqlFunctions.java|  9 +
 .../main/java/org/apache/calcite/sql/SqlKind.java   |  3 +++
 .../apache/calcite/sql/fun/SqlLibraryOperators.java |  7 +++
 .../org/apache/calcite/sql/type/ReturnTypes.java| 21 +
 .../apache/calcite/sql/type/SqlTypeTransforms.java  | 11 +++
 .../org/apache/calcite/sql/type/SqlTypeUtil.java| 10 ++
 .../java/org/apache/calcite/util/BuiltInMethod.java |  1 +
 site/_docs/reference.md |  1 +
 .../org/apache/calcite/test/SqlOperatorTest.java| 14 ++
 10 files changed, 79 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 620926cf34..925bbec92e 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -172,6 +172,7 @@ import static 
org.apache.calcite.sql.fun.SqlLibraryOperators.LOG;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_AND;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_OR;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.LPAD;
+import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_ENTRIES;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_KEYS;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_VALUES;
 import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAX_BY;
@@ -693,6 +694,7 @@ public class RexImpTable {
   defineMethod(ARRAY_REPEAT, BuiltInMethod.ARRAY_REPEAT.method, 
NullPolicy.NONE);
   defineMethod(ARRAY_REVERSE, BuiltInMethod.ARRAY_REVERSE.method, 
NullPolicy.STRICT);
   defineMethod(ARRAY_SIZE, BuiltInMethod.COLLECTION_SIZE.method, 
NullPolicy.STRICT);
+  defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method, 
NullPolicy.STRICT);
   defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT);
   defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method, 
NullPolicy.STRICT);
   map.put(ARRAY_CONCAT, new ArrayConcatImplementor());
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java 
b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index e47a2d86f9..8c68768d1b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -3898,6 +3898,15 @@ public class SqlFunctions {
 return Collections.nCopies(numberOfElement, element);
   }
 
+  /** Support the MAP_ENTRIES function. */
+  public static List mapEntries(Map map) {
+final List result = new ArrayList(map.size());
+for (Map.Entry entry : map.entrySet()) {
+  result.add(Arrays.asList(entry.getKey(), entry.getValue()));
+}
+return result;
+  }
+
   /** Support the MAP_KEYS function. */
   public static List mapKeys(Map map) {
 return new ArrayList<>(map.keySet());
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlKind.java 
b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
index f8e10a41f4..b1f18b7136 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlKind.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
@@ -695,6 +695,9 @@ public enum SqlKind {
   /** {@code ARRAY_SIZE} function (Spark semantics). */
   ARRAY_SIZE,
 
+  /** {@code MAP_ENTRIES} function (Spark semantics). */
+  MAP_ENTRIES,
+
   /** {@code MAP_KEYS} function (Spark semantics). */
   MAP_KEYS,
 
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 476024dad5..bcc6e3fa1f 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
@@ -923,6 +923,13 @@ public abstract class SqlLibraryOperators {
   ReturnTypes.LEAST_RESTRICTIVE,
   OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
+  /** The "MAP_ENTRIES(map)" function. */
+  @LibraryOperator(libraries = {SPARK})
+  public static final SqlFunction MAP_ENTRIES =
+  SqlBasicFunction.create(SqlKind.MAP_ENTRIES,
+  ReturnTypes.TO_MAP_ENTRIES_NULLABLE,
+  

[GitHub] [calcite] JiajunBernoulli merged pull request #3218: [CALCITE-5714] Add MAP_ENTRIES function (enabled in Spark library)

2023-06-02 Thread via GitHub


JiajunBernoulli merged PR #3218:
URL: https://github.com/apache/calcite/pull/3218


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3113:
URL: https://github.com/apache/calcite/pull/3113#issuecomment-1573702941

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3113)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
   
   
[![69.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'69.6%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
 [69.6% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3238: [CALCITE-5744] Add STR_TO_MAP function (enabled in Spark library)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3238:
URL: https://github.com/apache/calcite/pull/3238#issuecomment-1573597402

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3238)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3238=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
 [15 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3238=false=CODE_SMELL)
   
   
[![96.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'96.2%')](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_coverage=list)
 [96.2% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3238=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs commented on pull request #3238: [CALCITE-5744] Add STR_TO_MAP function (enabled in Spark library)

2023-06-02 Thread via GitHub


liuyongvs commented on PR #3238:
URL: https://github.com/apache/calcite/pull/3238#issuecomment-1573584337

   hi @JiajunBernoulli @tanclary @MasseGuillaume  do you have time to review 
this ,just review STR_TO_MAP and after
   the former commits merged, i will rebase it.otherwise, it will lots of 
conflict


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs commented on pull request #3239: [CALCITE-5739] Add MAP_FROM_ARRAYS function (enabled in Spark library)

2023-06-02 Thread via GitHub


liuyongvs commented on PR #3239:
URL: https://github.com/apache/calcite/pull/3239#issuecomment-1573582884

   hi @JiajunBernoulli @tanclary @MasseGuillaume do you have time to review 
this ,just review  MAP_FROM_ARRAYS and after
   the MAP_ENTRIES merged, i will rebase it.otherwise, it will lots of conflict


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs opened a new pull request, #3239: [CALCITE-5739] Add MAP_FROM_ARRAYS function (enabled in Spark library)

2023-06-02 Thread via GitHub


liuyongvs opened a new pull request, #3239:
URL: https://github.com/apache/calcite/pull/3239

   MAP_FROM_ARRAYS (array1, array2)
   
   Returns a map created from an array1 and *array2. Note that the lengths of 
two arrays should be the same
   
   ```
   > SELECT map_from_arrays(array(1.0, 3.0), array('2', '4'));
{1.0:"2",3.0:"4"} 
   ```


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] liuyongvs opened a new pull request, #3238: [CALCITE-5744] Add STR_TO_MAP function (enabled in Spark library)

2023-06-02 Thread via GitHub


liuyongvs opened a new pull request, #3238:
URL: https://github.com/apache/calcite/pull/3238

    STR_TO_MAP(string[, stringDelimiter[, keyValueDelimiter]])
   
   Returns a map after splitting the string into key/value pairs using 
delimiters. Default delimiters are ',' for stringDelimiter and ':' for 
keyValueDelimiter Both pairDelim and keyValueDelim are treated as regular 
expressions.
   
   ```
   Examples:
   
   > SELECT str_to_map('a:1,b:2,c:3', ',', ':');
   
   - {"a":"1","b":"2","c":"3"}
   
   > SELECT str_to_map('a');
{"a":null} 
   ```
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] zstan commented on a diff in pull request #3211: [CALCITE-5708] Change SUBSTRING result if either of parameters is NULL

2023-06-02 Thread via GitHub


zstan commented on code in PR #3211:
URL: https://github.com/apache/calcite/pull/3211#discussion_r1214203114


##
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##
@@ -1042,6 +1042,10 @@ void testDyadicCollateOperator() {
 .columnType("VARCHAR(1) NOT NULL");
 expr("substring('a', 1, '3')")
 .columnType("VARCHAR(1) NOT NULL");
+
+expr("SUBSTRING(NULL FROM 1 FOR 2)").ok();

Review Comment:
   @herunkang2018 fixed, can you make a review plz ? I update description and 
starting code point in appropriate issue.



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] zabetak commented on a diff in pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


zabetak commented on code in PR #3113:
URL: https://github.com/apache/calcite/pull/3113#discussion_r1214176911


##
core/src/main/java/org/apache/calcite/util/Util.java:
##
@@ -1717,16 +1719,14 @@ private static void appendPosixTime(StringBuilder buf, 
int millis) {
* @return Java locale object
*/
   public static Locale parseLocale(String localeString) {
-String[] strings = localeString.split("_");
-switch (strings.length) {
-case 1:
-  return new Locale(strings[0]);
-case 2:
-  return new Locale(strings[0], strings[1]);
-case 3:
-  return new Locale(strings[0], strings[1], strings[2]);
-default:
-  throw new AssertionError("bad locale string '" + localeString + "'");
+if (localeString.isEmpty()) {
+  return Locale.ROOT;
+}
+try {
+  return new Locale.Builder().setLanguageTag(
+  UNDERSCORE.matcher(localeString).replaceAll("-")).build();
+} catch (IllformedLocaleException e) {
+  throw new AssertionError("bad locale string '" + localeString + "'", e);

Review Comment:
   A `IllegalStateException` or `IllegalArgumentException` would be more 
appropriate here but since it was an `AssertionError` before I am also fine 
leaving it as is.
   I don't think an `AssertionError` is appropriate cause we may arrive here by 
user input.



##
core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java:
##
@@ -738,17 +741,7 @@ public static ParsedCollation parseCollation(String in) {
 }
 
 Charset charset = SqlUtil.getCharset(charsetStr);
-String[] localeParts = localeStr.split("_");
-Locale locale;
-if (1 == localeParts.length) {
-  locale = new Locale(localeParts[0]);
-} else if (2 == localeParts.length) {
-  locale = new Locale(localeParts[0], localeParts[1]);
-} else if (3 == localeParts.length) {
-  locale = new Locale(localeParts[0], localeParts[1], localeParts[2]);
-} else {
-  throw RESOURCE.illegalLocaleFormat(localeStr).ex();

Review Comment:
   Instead of throwing a new `AssertionError` I think it is better to restore 
the `RESOURCE.illegalLocaleFormat`. Other than that the change LGTM.



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3237:
URL: https://github.com/apache/calcite/pull/3237#issuecomment-1573351880

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3237)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3237=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3237=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3237=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=CODE_SMELL)
 [4 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=CODE_SMELL)
   
   
[![94.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'94.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_coverage=list)
 [94.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] zoudan opened a new pull request, #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-02 Thread via GitHub


zoudan opened a new pull request, #3237:
URL: https://github.com/apache/calcite/pull/3237

   (no comment)


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3113:
URL: https://github.com/apache/calcite/pull/3113#issuecomment-1573248543

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3113)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3113=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3113=false=CODE_SMELL)
   
   
[![65.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'65.2%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
 [65.2% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3113=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3207: [CALCITE-5707] Add ARRAY_CONTAINS function (enabled in Spark library)

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3207:
URL: https://github.com/apache/calcite/pull/3207#issuecomment-1573224765

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3207)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3207=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3207=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3207=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3207=false=CODE_SMELL)
   
   
[![91.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'91.1%')](https://sonarcloud.io/component_measures?id=apache_calcite=3207=new_coverage=list)
 [91.1% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3207=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3207=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3207=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[calcite] branch main updated: [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort with offset

2023-06-02 Thread rubenql
This is an automated email from the ASF dual-hosted git repository.

rubenql 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 295df907d1  [CALCITE-5730] Initial null values can be dropped by 
EnumerableLimitSort with offset
295df907d1 is described below

commit 295df907d126ffa059756e2e0cc8b69051ff6da7
Author: guofeng.my 
AuthorDate: Thu Jun 1 17:06:50 2023 +0800

 [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort 
with offset
---
 .../test/enumerable/EnumerableLimitSortTest.java   | 172 +
 .../apache/calcite/linq4j/EnumerableDefaults.java  |   4 +-
 .../apache/calcite/linq4j/test/LimitSortTest.java  |  23 +--
 3 files changed, 187 insertions(+), 12 deletions(-)

diff --git 
a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
new file mode 100644
index 00..5c0d35ca4b
--- /dev/null
+++ 
b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableLimitSortTest.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test.enumerable;
+
+import org.apache.calcite.adapter.enumerable.EnumerableRules;
+import org.apache.calcite.adapter.java.ReflectiveSchema;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.test.CalciteAssert;
+import org.apache.calcite.test.schemata.hr.HrSchemaBig;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.function.Consumer;
+
+/** Tests for
+ * {@link org.apache.calcite.adapter.enumerable.EnumerableLimitSort}. */
+public class EnumerableLimitSortTest {
+
+  /** Test case for
+   * https://issues.apache.org/jira/browse/CALCITE-5730;>[CALCITE-5730]
+   * First nulls can be dropped by EnumerableLimitSort with offset. */
+  @Test void nullsFirstWithLimitAndOffset() {
+tester("select commission from emps order by commission nulls first limit 
1 offset 1 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[ASC-nulls-first], 
offset=[1], fetch=[1])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered("commission=null");
+  }
+
+  @Test void nullsLastWithLimitAndOffset() {
+tester("select commission from emps order by commission desc nulls last 
limit 8 offset 10 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[DESC-nulls-last], 
offset=[10], fetch=[8])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered(
+"commission=1000",
+"commission=1000",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500",
+"commission=500");
+  }
+
+  @Test void nullsFirstWithLimit() {
+tester("select commission from emps order by commission nulls first limit 
13 ")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ "  EnumerableLimitSort(sort0=[$4], dir0=[ASC-nulls-first], 
fetch=[13])\n"
++ "EnumerableTableScan(table=[[s, emps]])")
+.returnsOrdered(
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=null",
+"commission=250");
+  }
+
+  @Test void nullsLastWithLimit() {
+tester("select commission from emps order by commission nulls last limit 5 
")
+.explainContains("EnumerableCalc(expr#0..4=[{inputs}], 
commission=[$t4])\n"
++ 

[GitHub] [calcite] rubenada merged pull request #3228: [CALCITE-5730] Initial null values can be dropped by EnumerableLimitSort with offset

2023-06-02 Thread via GitHub


rubenada merged PR #3228:
URL: https://github.com/apache/calcite/pull/3228


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] snuyanzin commented on a diff in pull request #3113: [CALCITE-5567] Enable jdk19 in ci

2023-06-02 Thread via GitHub


snuyanzin commented on code in PR #3113:
URL: https://github.com/apache/calcite/pull/3113#discussion_r1213976159


##
site/_docs/history.md:
##
@@ -43,6 +43,10 @@ z.
  Breaking Changes
 {: #breaking-1-35-0}
 
+The way of Locale parsing changed within [https://issues.apache.org/jira/browse/CALCITE-5567;>CALCITE-5567]
+Now locales are parsed according to IETF BCP 47 language tag string.
+This leads to the fact that some locales not satisfying IETF BCP 47 language 
tag string.

Review Comment:
   yep, thanks for the catch
   I changed it 



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] sonarcloud[bot] commented on pull request #3212: [CALCITE-5710] Add ARRAY_MAX, ARRAY_MIN function (enabled in Spark li…

2023-06-02 Thread via GitHub


sonarcloud[bot] commented on PR #3212:
URL: https://github.com/apache/calcite/pull/3212#issuecomment-1573215321

   Kudos, SonarCloud Quality Gate passed!  [![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate 
passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3212)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3212=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3212=false=CODE_SMELL)
   
   
[![97.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'97.2%')](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_coverage=list)
 [97.2% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3212=new_duplicated_lines_density=list)
   
   


-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org