You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/08 11:59:00 UTC

[GitHub] [spark] AngersZhuuuu opened a new pull request, #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

AngersZhuuuu opened a new pull request, #37436:
URL: https://github.com/apache/spark/pull/37436

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1208850102

   Looks like UT failed not caused by this pr


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1212680763

   thanks, merging to master/3.3!


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan closed pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly
URL: https://github.com/apache/spark/pull/37436


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941255226


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   Caused by `ArrayType`'s `containsNull` is not reliable.  
   When use `Literal.create(Seq(1d), ArrayType(DoubleType))` this array's `containsNull` is also true



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r940888964


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   same question



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r942042163


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4158,7 +4158,8 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina
              |$nullElementIndex = $size;
              |$size++;
              |$builder.$$plus$$eq($nullValueHolder);
-           """.stripMargin)
+           """.stripMargin,
+          Some(s"$hashSet.containsNull()"))

Review Comment:
   The interpreted code path is:
   ```
             val withArray1NullCheckFunc = SQLOpenHashSet.withNullCheckFunc(elementType, hsResult,
               (value: Any) => withArray1NaNCheckFunc(value),
               () =>
                 if (hs.containsNull()) {
                   arrayBuffer += null
                 }
             )
   ```
   Can we follow it in the codegen path? e.g. `handleNull` should check `if (hashSet.containsNull())`



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1212685466

   > @AngersZhuuuu can you create 2 more PRs for 3.2 and 3.1? thanks!
   
   Sure


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] tgravescs commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
tgravescs commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1208133368

   @HyukjinKwon 


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1217456227

   @AngersZhuuuu do you know which refactor PR caused this bug?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941954131


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   > Why is the implementation different from interpreted path? e.g., `SQLOpenHashSet.withNullCheckFunc`
   
   Their own code generation methods are different. There will be containsNull related judgments in codegen, so the extraction methods are different. The problem this time is caused by the surface problem of the wrong understanding of the field.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r942050637


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4158,7 +4158,8 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina
              |$nullElementIndex = $size;
              |$size++;
              |$builder.$$plus$$eq($nullValueHolder);
-           """.stripMargin)
+           """.stripMargin,
+          Some(s"$hashSet.containsNull()"))

Review Comment:
   Updated



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1211530651

   Any more suggestion?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r940881260


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   Why is the implementation different from interpreted path? e.g., `SQLOpenHashSet.withNullCheckFunc`



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r943145738


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4155,9 +4155,11 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina
           right.dataType.asInstanceOf[ArrayType].containsNull,
           array1, i, hashSetResult, withArray1NaNCheckCodeGenerator,
           s"""
-             |$nullElementIndex = $size;
-             |$size++;
-             |$builder.$$plus$$eq($nullValueHolder);
+             |if ($hashSet.containsNull()) {

Review Comment:
   does ArrayExcept have the bug?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1217494585

   > @AngersZhuuuu do you know which refactor PR caused this bug?
   
   https://issues.apache.org/jira/browse/SPARK-36829


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1209506723

   https://github.com/apache/spark/pull/37436#discussion_r941255226 You did not answer the question. Why it's only an issue with codegen?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r943147717


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4155,9 +4155,11 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina
           right.dataType.asInstanceOf[ArrayType].containsNull,
           array1, i, hashSetResult, withArray1NaNCheckCodeGenerator,
           s"""
-             |$nullElementIndex = $size;
-             |$size++;
-             |$builder.$$plus$$eq($nullValueHolder);
+             |if ($hashSet.containsNull()) {

Review Comment:
   No



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941300567


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   How about current's code path?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1214736217

   Hi, @cloud-fan .
   Could you update Apache JIRA, https://issues.apache.org/jira/browse/SPARK-39976 ?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r940880217


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   ```suggestion
              |  if (!$hashSet.containsNull()${nullConditions.map(" && " + _).mkString)}) {
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941259665


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   The whole stage codegen's code seems wrong ....in origins code it's ok seems it use a flag foundNullElement to flag if array2 contains null.
   
   ```
           def withArray1NullAssignment(body: String) =
             if (left.dataType.asInstanceOf[ArrayType].containsNull) {
               if (right.dataType.asInstanceOf[ArrayType].containsNull) {
                 s"""
                    |if ($array1.isNullAt($i)) {
                    |  if ($foundNullElement) {
                    |    $nullElementIndex = $size;
                    |    $foundNullElement = false;
                    |    $size++;
                    |    $builder.$$plus$$eq($nullValueHolder);
                    |  }
                    |} else {
                    |  $body
                    |}
                  """.stripMargin
               } else {
                 s"""
                    |if (!$array1.isNullAt($i)) {
                    |  $body
                    |}
                  """.stripMargin
               }
             } else {
               body
             }
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1208060179

   ping @cloud-fan @tgravescs 


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1212681143

   @AngersZhuuuu can you create 2 more PRs for 3.2 and 3.1? 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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r943147717


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4155,9 +4155,11 @@ case class ArrayIntersect(left: Expression, right: Expression) extends ArrayBina
           right.dataType.asInstanceOf[ArrayType].containsNull,
           array1, i, hashSetResult, withArray1NaNCheckCodeGenerator,
           s"""
-             |$nullElementIndex = $size;
-             |$size++;
-             |$builder.$$plus$$eq($nullValueHolder);
+             |if ($hashSet.containsNull()) {

Review Comment:
   No, and add same UT of `ArrayExcept`, should we remove the added test case about `ArrayExcept`?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1210076322

   > [#37436 (comment)](https://github.com/apache/spark/pull/37436#discussion_r941255226) You did not answer the question. Why it's only an issue with codegen?
   
   Update it in the pr desc


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941255226


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   Caused by `ArrayType`'s `containsNull` just means it can contains null, not really mean in this array contains a null, we should pass another flag to this function to mark array 2 contain a null element.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1208895866

   cc @rednaxelafx FYI


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on a diff in pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on code in PR #37436:
URL: https://github.com/apache/spark/pull/37436#discussion_r941259665


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala:
##########
@@ -85,12 +85,13 @@ object SQLOpenHashSet {
       index: String,
       hashSet: String,
       handleNotNull: (String, String) => String,
-      handleNull: String): String = {
+      handleNull: String,
+      nullConditions: Seq[String] = Seq.empty): String = {
     if (arrayContainsNull) {
       if (setContainsNull) {
         s"""
            |if ($array.isNullAt($index)) {
-           |  if (!$hashSet.containsNull()) {
+           |  if (!$hashSet.containsNull()${nullConditions.map(" &&" + _).mkString("")}) {

Review Comment:
   The whole stage codegen's code seems wrong ....in origins code it's ok seems it use a flag foundNullElement to flag if array2 contains null.
   
   ```
           def withArray1NullAssignment(body: String) =
             if (left.dataType.asInstanceOf[ArrayType].containsNull) {
               if (right.dataType.asInstanceOf[ArrayType].containsNull) {
                 s"""
                    |if ($array1.isNullAt($i)) {
                    |  if ($foundNullElement) {
                    |    $nullElementIndex = $size;
                    |    $foundNullElement = false;
                    |    $size++;
                    |    $builder.$$plus$$eq($nullValueHolder);
                    |  }
                    |} else {
                    |  $body
                    |}
                  """.stripMargin
               } else {
                 s"""
                    |if (!$array1.isNullAt($i)) {
                    |  $body
                    |}
                  """.stripMargin
               }
             } else {
               body
             }
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AngersZhuuuu commented on pull request #37436: [SPARK-39976][SQL] ArrayIntersect should handle null in left expression correctly

Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on PR #37436:
URL: https://github.com/apache/spark/pull/37436#issuecomment-1217401821

   > @AngersZhuuuu can you create 2 more PRs for 3.2 and 3.1? thanks!
   
   After check, 3.2 and 3.1 don't have this problem, this problem is caused by the refactor pr


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org