You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "zabetak (via GitHub)" <gi...@apache.org> on 2025/04/28 14:55:11 UTC

[PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

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

   (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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak commented on PR #4345:
URL: https://github.com/apache/calcite/pull/4345#issuecomment-2841042320

   I forgot to squash the commits so I rebased and forced push the following commit: https://github.com/apache/calcite/commit/1919f8e90305fca997588009bed0ce87ced06011 


-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2067884716


##########
core/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -1874,6 +1874,7 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {
       return literal.getValueAs(clazz);
 
     case ROW:
+    case ARRAY_VALUE_CONSTRUCTOR:

Review Comment:
   Recorded as ISSUE  https://issues.apache.org/jira/browse/CALCITE-6993



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2066188356


##########
core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java:
##########
@@ -960,6 +960,22 @@ private void checkDate(RexLiteral literal) {
     assertThat(inCall.getKind(), is(SqlKind.SEARCH));
   }
 
+  @Test void testMakeInWithArrayLiterals() {
+    RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
+    RexBuilder rexBuilder = new RexBuilder(typeFactory);
+    RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+    RelDataType arrayIntType = typeFactory.createArrayType(intType, -1);
+    RexNode column = rexBuilder.makeInputRef(arrayIntType, 0);
+    RexNode l1 = rexBuilder.makeLiteral(ImmutableList.of(100, 200), arrayIntType, false);
+    RexNode l2 = rexBuilder.makeLiteral(ImmutableList.of(300, 400), arrayIntType, false);
+    RexNode inCall = rexBuilder.makeIn(column, ImmutableList.of(l1, l2));
+    assertThat(
+        inCall, hasToString("SEARCH($0, Sarg["
+        + "[100:INTEGER, 200:INTEGER]:INTEGER NOT NULL ARRAY, "

Review Comment:
   The type of the Sarg literal is indeed `INTEGER NOT NULL ARRAY NOT NULL` despite the fact that it does not appear in the `toString` representation. 
   
   There are various inconsistencies and potentially redundant information in the digest/toString of Sarg literals but it's outside the scope of this PR. If we want to change the `toString` representation then it would be better to do in a separate JIRA.



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2066180515


##########
core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java:
##########
@@ -960,6 +960,22 @@ private void checkDate(RexLiteral literal) {
     assertThat(inCall.getKind(), is(SqlKind.SEARCH));
   }
 
+  @Test void testMakeInWithArrayLiterals() {

Review Comment:
   Fixed in https://github.com/apache/calcite/pull/4345/commits/280190b4be82f8fdb4c87096eed3ddb9d6ed863d



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2065219674


##########
core/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -1874,6 +1874,7 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {
       return literal.getValueAs(clazz);
 
     case ROW:
+    case ARRAY_VALUE_CONSTRUCTOR:

Review Comment:
   Shouldn't we also incorporate `MULTISET_VALUE_CONSTRUCTOR` to support `MULTISET`?



##########
core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java:
##########
@@ -960,6 +960,22 @@ private void checkDate(RexLiteral literal) {
     assertThat(inCall.getKind(), is(SqlKind.SEARCH));
   }
 
+  @Test void testMakeInWithArrayLiterals() {
+    RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
+    RexBuilder rexBuilder = new RexBuilder(typeFactory);
+    RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+    RelDataType arrayIntType = typeFactory.createArrayType(intType, -1);
+    RexNode column = rexBuilder.makeInputRef(arrayIntType, 0);
+    RexNode l1 = rexBuilder.makeLiteral(ImmutableList.of(100, 200), arrayIntType, false);
+    RexNode l2 = rexBuilder.makeLiteral(ImmutableList.of(300, 400), arrayIntType, false);
+    RexNode inCall = rexBuilder.makeIn(column, ImmutableList.of(l1, l2));
+    assertThat(
+        inCall, hasToString("SEARCH($0, Sarg["
+        + "[100:INTEGER, 200:INTEGER]:INTEGER NOT NULL ARRAY, "

Review Comment:
   If NULL is maintained as uniform, the output here should be `INTEGER NOT NULL ARRAY NOT NULL`, which is more explicit.



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak commented on PR #4345:
URL: https://github.com/apache/calcite/pull/4345#issuecomment-2841034468

   Thanks for the reviews @xiedeyantu , @asolimando , @NobiGo !


-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2066191844


##########
core/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -1874,6 +1874,7 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {
       return literal.getValueAs(clazz);
 
     case ROW:
+    case ARRAY_VALUE_CONSTRUCTOR:

Review Comment:
   We could but it could be done as a separate PR with its own tests since it is an independent enhancement.



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4345:
URL: https://github.com/apache/calcite/pull/4345#issuecomment-2838603019

   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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2067884716


##########
core/src/main/java/org/apache/calcite/rex/RexBuilder.java:
##########
@@ -1874,6 +1874,7 @@ && areAssignable(arg, Arrays.asList(lower, upper))) {
       return literal.getValueAs(clazz);
 
     case ROW:
+    case ARRAY_VALUE_CONSTRUCTOR:

Review Comment:
   Recorded as ISSUE  https://issues.apache.org/jira/browse/CALCITE-6993 and https://issues.apache.org/jira/browse/CALCITE-6994



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4345:
URL: https://github.com/apache/calcite/pull/4345#discussion_r2063869699


##########
core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java:
##########
@@ -960,6 +960,22 @@ private void checkDate(RexLiteral literal) {
     assertThat(inCall.getKind(), is(SqlKind.SEARCH));
   }
 
+  @Test void testMakeInWithArrayLiterals() {

Review Comment:
   Do we need to add a Jira link on this method?



-- 
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-unsubscribe@calcite.apache.org

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


Re: [PR] [CALCITE-6989] Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals [calcite]

Posted by "zabetak (via GitHub)" <gi...@apache.org>.
zabetak merged PR #4345:
URL: https://github.com/apache/calcite/pull/4345


-- 
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-unsubscribe@calcite.apache.org

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