You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xuzifu666 (via GitHub)" <gi...@apache.org> on 2025/02/17 15:24:59 UTC

[PR] [CALCITE-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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

   As describe in JIRA:https://issues.apache.org/jira/browse/CALCITE-6844


-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   Yes, I had submit a issue in Spark JIRA: https://issues.apache.org/jira/browse/SPARK-51319 @rubenada 



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   Have you checked the results of executing different parameters or values in Hive? The descriptions on the official website are often not detailed enough.



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   Have you checked the results of executing different parameters or values in Hive?



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
site/_docs/reference.md:
##########
@@ -2785,24 +2785,24 @@ In the following:
 | s | ARRAY_APPEND(array, element)                   | Appends an *element* to the end of the *array* and returns the result. Type of *element* should be similar to type of the elements of the *array*. If the *array* is null, the function will return null. If an *element* that is null, the null *element* will be added to the end of the *array*
 | s | ARRAY_COMPACT(array)                           | Removes null values from the *array*
 | b | ARRAY_CONCAT(array [, array ]*)                | Concatenates one or more arrays. If any input argument is `NULL` the function returns `NULL`
-| s | ARRAY_CONTAINS(array, element)                 | Returns true if the *array* contains the *element*
-| s | ARRAY_DISTINCT(array)                          | Removes duplicate values from the *array* that keeps ordering of elements
-| s | ARRAY_EXCEPT(array1, array2)                   | Returns an array of the elements in *array1* but not in *array2*, without duplicates
+| h s | ARRAY_CONTAINS(array, element)               | Returns true if the *array* contains the *element*

Review Comment:
   Shouldn't we add the `h` also on the ARRAY operator? (line 2784)



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   Thanks for checking @xuzifu666 , has a ticket been created for that bug in Spark?



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   Thanks for your reminder, had change array_contains with Spark, other array functions I would check it again. @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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8062,146 +8062,158 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
     f.checkNull("array_concat(cast(null as integer array), array[1])");
   }
 
-  /** Tests {@code ARRAY_CONTAINS} function from Spark. */
+  /** Tests {@code ARRAY_CONTAINS} function from Spark、Hive. */

Review Comment:
   Done



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   ``` 
   select array_contains(array(1,null),2);
   ```
   In Spark, returns NULL
   But In Hive, it returns FALSE
   This cannot be the same function.



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8062,146 +8062,158 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
     f.checkNull("array_concat(cast(null as integer array), array[1])");
   }
 
-  /** Tests {@code ARRAY_CONTAINS} function from Spark. */
+  /** Tests {@code ARRAY_CONTAINS} function from Spark、Hive. */

Review Comment:
   Sorry but the change is incomplete: you modified one ocurrence, but there are still 7 more occurrences of this character that your PR has introduced throughout this file, could you please correct them?



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8062,146 +8062,158 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
     f.checkNull("array_concat(cast(null as integer array), array[1])");
   }
 
-  /** Tests {@code ARRAY_CONTAINS} function from Spark. */
+  /** Tests {@code ARRAY_CONTAINS} function from Spark、Hive. */

Review Comment:
   Not the usual comma that we normally use, please change it (8 occurrences in this file) (`、` => `,` )



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4202:
URL: https://github.com/apache/calcite/pull/4202#issuecomment-2684406105

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4202) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4202&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4202&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4202&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4202&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [29.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4202&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4202)
   
   


-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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

   LGTM
   @NobiGo do you have other remarks?


-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   > ```
   > select array_contains(array(1,null),2);
   > ```
   > 
   > In Spark, returns NULL But In Hive, it returns FALSE This cannot be the same function.
   
   According discussion with Spark community offline,this is a bug of spark,and here array_contains(array(1,null),2) should return false not null, at the same time test array_contains(array(1, null),1) would return true in Spark,can we not consider about it currently?other functions test is well with different parameters.  @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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   > ```
   > select array_contains(array(1,null),2);
   > ```
   > 
   > In Spark, returns NULL But In Hive, it returns FALSE This cannot be the same function.
   
   According discussion with Spark community,this is a bug of spark,and here array_contains(array(1,null),2) should return false not null, at the same time test array_contains(array(1, null),1) would return true in Spark,can we not consider about it currently?other functions test is well with different parameters.  @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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
site/_docs/reference.md:
##########
@@ -2785,24 +2785,24 @@ In the following:
 | s | ARRAY_APPEND(array, element)                   | Appends an *element* to the end of the *array* and returns the result. Type of *element* should be similar to type of the elements of the *array*. If the *array* is null, the function will return null. If an *element* that is null, the null *element* will be added to the end of the *array*
 | s | ARRAY_COMPACT(array)                           | Removes null values from the *array*
 | b | ARRAY_CONCAT(array [, array ]*)                | Concatenates one or more arrays. If any input argument is `NULL` the function returns `NULL`
-| s | ARRAY_CONTAINS(array, element)                 | Returns true if the *array* contains the *element*
-| s | ARRAY_DISTINCT(array)                          | Removes duplicate values from the *array* that keeps ordering of elements
-| s | ARRAY_EXCEPT(array1, array2)                   | Returns an array of the elements in *array1* but not in *array2*, without duplicates
+| h s | ARRAY_CONTAINS(array, element)               | Returns true if the *array* contains the *element*

Review Comment:
   Done, thanks for the reminder. @rubenada 



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1508,21 +1508,21 @@ private static RelDataType arrayCompactReturnType(SqlOperatorBinding opBinding)
           OperandTypes.AT_LEAST_ONE_SAME_VARIADIC);
 
   /** The "ARRAY_CONTAINS(array, element)" function. */
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, HIVE})

Review Comment:
   > ```
   > select array_contains(array(1,null),2);
   > ```
   > 
   > In Spark, returns NULL But In Hive, it returns FALSE This cannot be the same function.
   
   According discussion with Spark community offline,this is a bug of spark,and here array_contains(array(1,null),2) should return false not null, at the same time test array_contains(array(1, null),1) would return true in Spark,can we not consider about it currently?other array functions test is well with different parameters.  @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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8062,146 +8062,158 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
     f.checkNull("array_concat(cast(null as integer array), array[1])");
   }
 
-  /** Tests {@code ARRAY_CONTAINS} function from Spark. */
+  /** Tests {@code ARRAY_CONTAINS} function from Spark、Hive. */

Review Comment:
   Done,Thanks @rubenada 



-- 
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-6844] Add all array spark functions which also support in Hive(enable in Hive Library) [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 closed pull request #4202: [CALCITE-6844] Add all array spark functions which also support in Hive(enable in Hive Library)
URL: https://github.com/apache/calcite/pull/4202


-- 
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