[GitHub] [calcite] liuyongvs commented on a diff in pull request #3262: [CALCITE-5772] Add MAP_CONCAT, MAP_FROM_ENTRIES function (enabled in …

2023-06-12 Thread via GitHub


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


##
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##
@@ -1005,6 +1012,23 @@ private static RelDataType 
arrayReturnType(SqlOperatorBinding opBinding) {
   ReturnTypes.TO_MAP_VALUES_NULLABLE,
   OperandTypes.MAP);
 
+  private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding 
opBinding) {
+final RelDataType entriesType = opBinding.collectOperandTypes().get(0);
+final RelDataType entryType = entriesType.getComponentType();
+return SqlTypeUtil.createMapType(
+opBinding.getTypeFactory(),
+requireNonNull(entryType.getFieldList().get(0).getType(), "inferred 
key type"),
+requireNonNull(entryType.getFieldList().get(1).getType(), "inferred 
value type"),
+entriesType.isNullable() || entryType.isNullable());
+  }
+

Review Comment:
   comments:
   ```
   comments:
   
   because my other prs will conflict it, so i don't submit it now. so i add an 
summary:
   
   the spark MAP_FROM_ENTRIES nullable have 2 case:
   
   1) input is nullable
   
   2) array, which contains null entry like this ,it will also return null
   
   so we should take this into consideration, type and result, i will add 
comment in the pr when you review you will see
   
   // spark
   spark-sql> select map_from_entries(array(struct(1, 'a'), null));
   NULL 
   
   // calcite should test this
   f.checkNull("map_from_entries(array[row(1, 'a'), null])");
   f.checkType("map_from_entries(array[row(1, 'a'), null])",
   "(INTEGER, CHAR(1)) MAP");

   
   case class MapFromEntries(child: Expression)
 extends UnaryExpression
 with NullIntolerant
 with QueryErrorsBase {
   
 @transient
 private lazy val dataTypeDetails: Option[(MapType, Boolean, Boolean)] = 
child.dataType match {
   case ArrayType(
 StructType(Array(
   StructField(_, keyType, keyNullable, _),
   StructField(_, valueType, valueNullable, _))),
 containsNull) => Some((MapType(keyType, valueType, valueNullable), 
keyNullable, containsNull))
   case _ => None
 }
   
 @transient private lazy val nullEntries: Boolean = dataTypeDetails.get._3
   
 override def nullable: Boolean = child.nullable || nullEntries
   ```



-- 
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, #3262: [CALCITE-5772] Add MAP_CONCAT, MAP_FROM_ENTRIES function (enabled in …

2023-06-12 Thread via GitHub


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

   
[map_concat](https://spark.apache.org/docs/latest/api/sql/index.html#map_concat)
   
   map_concat(map, ...) - Returns the union of all the given maps
   
   Examples:
   ```
   > SELECT map_concat(map(1, 'a', 2, 'b'), map(3, 'c'));
{1:"a",2:"b",3:"c"} 
   ```
   
[map_from_entries](https://spark.apache.org/docs/latest/api/sql/index.html#map_from_entries)
   
   map_from_entries(arrayOfEntries) - Returns a map created from the given 
array of entries.
   
   Examples:
   
   ```
   > SELECT map_from_entries(array(struct(1, 'a'), struct(2, 'b')));
{1:"a",2:"b"}
   ```


-- 
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-12 Thread via GitHub


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

   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)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=CODE_SMELL)
   
   
[![92.5%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'92.5%')](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_coverage=list)
 [92.5% 
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 commented on pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


zoudan commented on PR #3237:
URL: https://github.com/apache/calcite/pull/3237#issuecomment-1588407339

   > @liuyongvs @JiajunBernoulli thanks for your comments in the PR, do you 
have further remarks? Shall we consider squash commits and merge?
   
   I have squashed 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 #3054: (do not check in)

2023-06-12 Thread via GitHub


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

   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)
 [9 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
   
   
[![93.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'93.4%')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_coverage=list)
 [93.4% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_coverage=list)
  
   
[![0.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.8%')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_duplicated_lines_density=list)
 [0.8% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3054=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 #3054: (do not check in)

2023-06-12 Thread via GitHub


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

   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)
 [9 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3054=false=CODE_SMELL)
   
   
[![93.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'93.3%')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_coverage=list)
 [93.3% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_coverage=list)
  
   
[![0.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.8%')](https://sonarcloud.io/component_measures?id=apache_calcite=3054=new_duplicated_lines_density=list)
 [0.8% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3054=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] HanumathRao commented on a diff in pull request #3193: [CALCITE-5683] Two level nested correlated subquery throws an excepti…

2023-06-12 Thread via GitHub


HanumathRao commented on code in PR #3193:
URL: https://github.com/apache/calcite/pull/3193#discussion_r1227350034


##
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##
@@ -6823,6 +6823,50 @@ private void checkSemiJoinRuleOnAntiJoin(RelOptRule 
rule) {
 .checkUnchanged();
   }
 
+  /** Test case for CALCITE-5683 for two level nested decorrelate with 
standard program
+   * failing during the decorrelation phase. */
+  @Test void testTwoLevelDecorrelate() {
+final String sql = "SELECT d1.name, d1.deptno + "
++ " ( SELECT e1.empno "
++ " FROM emp e1 "
++ " WHERE d1.deptno = e1.deptno and "
++ "   e1.sal = (SELECT max(sal) "
++ " FROM emp e2 "
++ " WHERE   e1.sal = e2.sal and"
++ " e1.deptno = e2.deptno and"
++ " d1.deptno < e2.deptno))"
++ " FROM dept d1";
+
+sql(sql)
+.withExpand(false)
+.withLateDecorrelate(true)
+.withSubQueryRules()
+.withTrim(true)
+.withRule()
+.checkUnchanged();
+  }
+
+  /** Test case for CALCITE-5683 for two level nested decorrelate with 
standard program
+   * failing during the decorrelation phase. */
+  @Test void testTwoLevelDecorrelateSkipInBetween() {

Review Comment:
   By SkipInBetween, I actually mean't that the correlation variable is not 
used at the first level and directly used at the deeper level (here second 
level depth). I wanted to make sure that even if there is no correlation used 
in the intermediate levels, the solution works.



-- 
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 pull request #3211: [CALCITE-5708] Change SUBSTRING result if either of parameters is NULL

2023-06-12 Thread via GitHub


zstan commented on PR #3211:
URL: https://github.com/apache/calcite/pull/3211#issuecomment-1587136406

   @herunkang2018 kindly remind help with review if possible, 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] YasuoStudyJava commented on a diff in pull request #3247: [CALCITE-5733] Simplify "a = ARRAY[1,2] AND a = ARRAY[2,3]" to "false"

2023-06-12 Thread via GitHub


YasuoStudyJava commented on code in PR #3247:
URL: https://github.com/apache/calcite/pull/3247#discussion_r1226182776


##
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##
@@ -2660,6 +2695,24 @@ private Comparison(RexNode ref, SqlKind kind, RexLiteral 
literal) {
 return new Comparison(left, e.getKind(), (RexLiteral) right);
   }
   break;
+//add for RexCall like "CAST(ARRAY(..., ...))..."
+case CAST:
+  final RexCall castCall = (RexCall) right;
+  final RexNode castLeft = castCall.getOperands().get(0);
+  switch (castLeft.getKind()) {
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall
+  if (nodePredicate.test(left)) {
+return new Comparison(left, e.getKind(), (RexCall) castLeft);
+  }
+  }
+  break;
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall

Review Comment:
   @zoudan Thank you. Maybe I will take your suggestion later on.
   



-- 
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 MAP_FROM_ARRAYS, STR_TO_MAP function (enabled in Spark library)

2023-06-12 Thread via GitHub


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

   hi @tanclary @MasseGuillaume do you have time to look again? thank you


-- 
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] rubenada commented on pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


rubenada commented on PR #3237:
URL: https://github.com/apache/calcite/pull/3237#issuecomment-1586934659

   @liuyongvs @liuyongvs thanks for your comments in the PR, do you have 
further remarks? Shall we consider squash commits and merge?


-- 
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 #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


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


##
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
   .or(OperandTypes.family(SqlTypeFamily.MAP))
   .or(OperandTypes.family(SqlTypeFamily.ANY));
 
+  public static final SqlOperandTypeChecker 
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+  new FamilyOperandTypeChecker(

Review Comment:
   ok, i understand, thanks @zoudan 



-- 
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-12 Thread via GitHub


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

   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)
 [3 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_calcite=3237=false=CODE_SMELL)
   
   
[![92.5%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/90-16px.png
 
'92.5%')](https://sonarcloud.io/component_measures?id=apache_calcite=3237=new_coverage=list)
 [92.5% 
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 commented on a diff in pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


zoudan commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1226236342


##
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
   .or(OperandTypes.family(SqlTypeFamily.MAP))
   .or(OperandTypes.family(SqlTypeFamily.ANY));
 
+  public static final SqlOperandTypeChecker 
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+  new FamilyOperandTypeChecker(

Review Comment:
   @liuyongvs, If I understand correctly, what @rubenada meant was we should 
use `SqlTypeFamily.CHARACTER` instead of `SqlTypeFamily.STRING` for the second 
and third parameters. That make sense, I will update 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] zoudan commented on a diff in pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


zoudan commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1226236342


##
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
   .or(OperandTypes.family(SqlTypeFamily.MAP))
   .or(OperandTypes.family(SqlTypeFamily.ANY));
 
+  public static final SqlOperandTypeChecker 
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+  new FamilyOperandTypeChecker(

Review Comment:
   @liuyongvs, If I understand correctly, what @rubenada meant was we should 
use `SqlTypeFamily.CHARACTER` instead of `SqlTypeFamily.STRING` for the second 
and third parameters. That make sense, I will updated 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] liuyongvs commented on a diff in pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


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


##
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
   .or(OperandTypes.family(SqlTypeFamily.MAP))
   .or(OperandTypes.family(SqlTypeFamily.ANY));
 
+  public static final SqlOperandTypeChecker 
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+  new FamilyOperandTypeChecker(

Review Comment:
   @rubenada it can not be. refers to the bigquery's doc 
https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array_to_string,
 the array's element type should be check in compiler process.



-- 
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] rubenada commented on a diff in pull request #3237: [CALCITE-5728] Add ARRAY_TO_STRING function (enabled in BigQuery library)

2023-06-12 Thread via GitHub


rubenada commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1226207689


##
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
   .or(OperandTypes.family(SqlTypeFamily.MAP))
   .or(OperandTypes.family(SqlTypeFamily.ANY));
 
+  public static final SqlOperandTypeChecker 
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+  new FamilyOperandTypeChecker(

Review Comment:
   Good point, @liuyongvs. Since the STRING contains both CHARACTER and BINARY, 
I wonder if the type checker for the method should rather be 
`ImmutableList.of(SqlTypeFamily.ARRAY, SqlTypeFamily.CHARACTER, 
SqlTypeFamily.CHARACTER)` 



-- 
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 #3261: [CALCITE-5729] Support string as the input type for 'OCTET_LENGTH' and add 'BYTE_LENGTH' as an alias for 'OCTET_LENGTH' (enabled in

2023-06-12 Thread via GitHub


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

   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=3261)
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_calcite=3261=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=3261=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_calcite=3261=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=3261=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=3261=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite=3261=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=3261=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=3261=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3261=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=3261=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=3261=false=CODE_SMELL)
 [1 Code 
Smell](https://sonarcloud.io/project/issues?id=apache_calcite=3261=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=3261=new_coverage=list)
 [100.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_calcite=3261=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=3261=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_calcite=3261=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] YasuoStudyJava commented on a diff in pull request #3247: [CALCITE-5733] Simplify "a = ARRAY[1,2] AND a = ARRAY[2,3]" to "false"

2023-06-12 Thread via GitHub


YasuoStudyJava commented on code in PR #3247:
URL: https://github.com/apache/calcite/pull/3247#discussion_r1226182776


##
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##
@@ -2660,6 +2695,24 @@ private Comparison(RexNode ref, SqlKind kind, RexLiteral 
literal) {
 return new Comparison(left, e.getKind(), (RexLiteral) right);
   }
   break;
+//add for RexCall like "CAST(ARRAY(..., ...))..."
+case CAST:
+  final RexCall castCall = (RexCall) right;
+  final RexNode castLeft = castCall.getOperands().get(0);
+  switch (castLeft.getKind()) {
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall
+  if (nodePredicate.test(left)) {
+return new Comparison(left, e.getKind(), (RexCall) castLeft);
+  }
+  }
+  break;
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall

Review Comment:
   @zoudan OK, Thank you. I will take your suggestion later on. Now I am 
spending time on adding a unit test,but gradle is a bit unfamiliar to me. Maybe 
once I have configured the gradle, I can test the case.
   
   



-- 
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 commented on a diff in pull request #3247: [CALCITE-5733] Simplify "a = ARRAY[1,2] AND a = ARRAY[2,3]" to "false"

2023-06-12 Thread via GitHub


zoudan commented on code in PR #3247:
URL: https://github.com/apache/calcite/pull/3247#discussion_r1226169010


##
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##
@@ -672,9 +675,28 @@ private void simplifyAndTerms(List terms, 
RexUnknownAs unknownAs) {
 RexSimplify simplify = this;
 for (int i = 0; i < terms.size(); i++) {
   RexNode t = terms.get(i);
-  if (Predicate.of(t) == null) {
+  Predicate predicate = Predicate.of(t); 
+  if (predicate == null) {
 continue;
   }
+  
+  //add for array-type
+  if (predicate instanceof Comparison) {
+Comparison cmp = (Comparison) predicate;
+if (cmp.rexCall != null && 
cmp.rexCall.getKind().equals(SqlKind.ARRAY_VALUE_CONSTRUCTOR)) {

Review Comment:
   `SqlKind` is an enum type, you could use `==`



##
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##
@@ -2660,6 +2695,24 @@ private Comparison(RexNode ref, SqlKind kind, RexLiteral 
literal) {
 return new Comparison(left, e.getKind(), (RexLiteral) right);
   }
   break;
+//add for RexCall like "CAST(ARRAY(..., ...))..."
+case CAST:
+  final RexCall castCall = (RexCall) right;
+  final RexNode castLeft = castCall.getOperands().get(0);
+  switch (castLeft.getKind()) {
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall
+  if (nodePredicate.test(left)) {
+return new Comparison(left, e.getKind(), (RexCall) castLeft);
+  }
+  }
+  break;
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall

Review Comment:
   It is better to reuse the duplicate code.



##
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##
@@ -2669,10 +2722,28 @@ private Comparison(RexNode ref, SqlKind kind, 
RexLiteral literal) {
 return new Comparison(right, e.getKind().reverse(), (RexLiteral) 
left);
   }
   break;
+//add for RexCall like "CAST(ARRAY(..., ...))..."
+case CAST:
+  final RexCall castCall = (RexCall) left;
+  final RexNode castLeft = castCall.getOperands().get(0);
+  switch (castLeft.getKind()) {
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall
+  if (nodePredicate.test(right)) {
+return new Comparison(right, e.getKind().reverse(), (RexCall) 
castLeft);
+  }
+  }
+  break;
+case ARRAY_VALUE_CONSTRUCTOR:
+  //array-type RexCall --> create a comparison of RexCall
+  if (nodePredicate.test(right)) {
+return new Comparison(right, e.getKind().reverse(), (RexCall) 
left);
+  }
+  break;
 default:
   break;
 }
-break;
+break;

Review Comment:
   Do not add spaces at the end of lines



-- 
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, #3261: [CALCITE-5729] Support string as the input type for 'OCTET_LENGTH' and add 'BYTE_LENGTH' as an alias for 'OCTET_LENGTH' (enabled in BigQuery

2023-06-12 Thread via GitHub


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

   (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