You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "agubichev (via GitHub)" <gi...@apache.org> on 2023/05/24 00:27:01 UTC

[GitHub] [spark] agubichev opened a new pull request, #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

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

   <!--
   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?
   Makes sure that the results of scalar subqueries are declared as nullable. 
   
   ### 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.
   -->
   This is an existing correctness bug, see https://issues.apache.org/jira/browse/SPARK-43760
   
   ### Does this PR introduce _any_ user-facing change?
   Fixes a correctness issue, so it is user-facing.
   
   ### 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.
   -->
   Query tests.
   


-- 
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] bersprockets commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "bersprockets (via GitHub)" <gi...@apache.org>.
bersprockets commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1561760662

   Makes more sense now. Can you update the Jira as well?


-- 
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] agubichev commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "agubichev (via GitHub)" <gi...@apache.org>.
agubichev commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1561664367

   > Is there some setting needed to materialize the issue? Using the queries you added as tests (in `scalar-subquery-predicate.sql` and `scalar-subquery-select.sql`), I am getting your expected results on the master branch:
   > 
   > ```
   > spark-sql (default)> select version();
   > 3.5.0 5f325ec917ced819a19911b472ebf7eb52010203
   > Time taken: 2.69 seconds, Fetched 1 row(s)
   > spark-sql (default)> select *
   >                    > from range(1, 3) t1
   >                    > where (select sum(c) from (
   >                    >         select t2.id * t2.id c
   >                    >         from range (1, 2) t2 where t1.id = t2.id
   >                    >         group by t2.id
   >                    >        )
   >                    > ) is not null;
   > 1
   > Time taken: 1.141 seconds, Fetched 1 row(s)
   > spark-sql (default)> select *
   >                    > from
   >                    > (
   >                    >  select t1.id c1, (
   >                    >                     select sum(c)
   >                    >                     from (
   >                    >                       select t2.id * t2.id c
   >                    >                       from range (1, 2) t2 where t1.id = t2.id
   >                    >                       group by t2.id
   >                    >                     )
   >                    >                    ) c2
   >                    >  from range (1, 3) t1
   >                    > ) t
   >                    > where t.c2 is not null;
   > 1	1
   > Time taken: 0.404 seconds, Fetched 1 row(s)
   > spark-sql (default)> 
   > ```
   
   Great catch! I used the wrong query tests, updated them now. In both cases the results on the master branch are wrong:
   ```
   select * from (
    select [t1.id](http://t1.id/) c1, (
     select [t2.id](http://t2.id/) c from range (1, 2) t2
     where [t1.id](http://t1.id/) = [t2.id](http://t2.id/)  ) c2
    from range (1, 3) t1 ) t
   where t.c2 is not null
   -- !query schema
   struct<c1:bigint,c2:bigint>
   -- !query output
   1	1
   2	NULL
   
   ```
   and 
   
   ```
   -- !query
   select *
   from range(1, 3) t1
   where (select [t2.id](http://t2.id/) c
          from range (1, 2) t2 where [t1.id](http://t1.id/) = [t2.id](http://t2.id/)
         ) is not null
   -- !query schema
   struct<id:bigint>
   -- !query output
   1
   2
   ```
   
   -- in both queries the second row should not be present.


-- 
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] sigmod commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "sigmod (via GitHub)" <gi...@apache.org>.
sigmod commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1561680423

   @gengliangwang  @cloud-fan 


-- 
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 #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results
URL: https://github.com/apache/spark/pull/41287


-- 
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] agubichev commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "agubichev (via GitHub)" <gi...@apache.org>.
agubichev commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1561843655

   Updated Jira ticket too


-- 
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] bersprockets commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "bersprockets (via GitHub)" <gi...@apache.org>.
bersprockets commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1560343612

   Is there some setting needed to materialize the issue? Using the queries you added as tests (in `scalar-subquery-predicate.sql` and `scalar-subquery-select.sql`), I am getting your expected results on the master branch:
   ```
   spark-sql (default)> select version();
   3.5.0 5f325ec917ced819a19911b472ebf7eb52010203
   Time taken: 2.69 seconds, Fetched 1 row(s)
   spark-sql (default)> select *
                      > from range(1, 3) t1
                      > where (select sum(c) from (
                      >         select t2.id * t2.id c
                      >         from range (1, 2) t2 where t1.id = t2.id
                      >         group by t2.id
                      >        )
                      > ) is not null;
   1
   Time taken: 1.141 seconds, Fetched 1 row(s)
   spark-sql (default)> select *
                      > from
                      > (
                      >  select t1.id c1, (
                      >                     select sum(c)
                      >                     from (
                      >                       select t2.id * t2.id c
                      >                       from range (1, 2) t2 where t1.id = t2.id
                      >                       group by t2.id
                      >                     )
                      >                    ) c2
                      >  from range (1, 3) t1
                      > ) t
                      > where t.c2 is not null;
   1	1
   Time taken: 0.404 seconds, Fetched 1 row(s)
   spark-sql (default)> 
   ```


-- 
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 #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1569319412

   thanks, merging to master!


-- 
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 #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1569328005

   Thank you, @agubichev, @cloud-fan and all!
   According to the affected version, `3.4.0`, can we have this at `branch-3.4` too?


-- 
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 #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1569334014

   @agubichev can you open a backport PR for 3.4? 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] agubichev commented on pull request #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "agubichev (via GitHub)" <gi...@apache.org>.
agubichev commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1563084087

   Conflicts are resolved.


-- 
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 #41287: [SPARK-43760][SQL] Nullability of scalar subquery results

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #41287:
URL: https://github.com/apache/spark/pull/41287#issuecomment-1563005932

   LGTM, can we fix the conflicts?


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