Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-45507][SQL] Correctness fix for nested correlated scalar subqueries with COUNT aggregates #43341

Closed
wants to merge 16 commits into from

Conversation

andylam-db
Copy link
Contributor

@andylam-db andylam-db commented Oct 12, 2023

What changes were proposed in this pull request?

We want to use the count bug handling in DecorrelateInnerQuery to detect potential count bugs in scalar subqueries. it It is always safe to use DecorrelateInnerQuery to handle count bugs, but for efficiency reasons, like for the common case of COUNT on top of the scalar subquery, we would like to avoid an extra left outer join. This PR therefore introduces a simple check to detect such cases before decorrelate() - if true, then don't do count bug handling in decorrelate(), and vice-versa.

Why are the changes needed?

This PR fixes correctness issues for correlated scalar subqueries pertaining to the COUNT bug. Examples can be found in the JIRA ticket.

Does this PR introduce any user-facing change?

Yes, results will change.

How was this patch tested?

Added SQL end-to-end tests in count.sql

Was this patch authored or co-authored using generative AI tooling?

No.

@andylam-db andylam-db changed the title [SPARK-45507] Correctness fix for correlated scalar subqueries with COUNT aggregates [WIP][SPARK-45507][SQL] Correctness fix for correlated scalar subqueries with COUNT aggregates Oct 12, 2023
@github-actions github-actions bot added the SQL label Oct 12, 2023
@andylam-db
Copy link
Contributor Author

Pinging for first round of reviews :-) @jchen5 @agubichev

@andylam-db andylam-db changed the title [WIP][SPARK-45507][SQL] Correctness fix for correlated scalar subqueries with COUNT aggregates [SPARK-45507][SQL] Correctness fix for correlated scalar subqueries with COUNT aggregates Oct 12, 2023
@andylam-db andylam-db changed the title [SPARK-45507][SQL] Correctness fix for correlated scalar subqueries with COUNT aggregates [SPARK-45507][SQL] Correctness fix for nested correlated scalar subqueries with COUNT aggregates Oct 13, 2023
@andylam-db
Copy link
Contributor Author

andylam-db commented Oct 17, 2023

@cloud-fan Failed tests in build. I think the first one is unrelated to the PR, but not sure about the second one. Should we merge?

  1. Docker integration tests:
[error] Error during tests:
[error] 	org.apache.spark.sql.jdbc.v2.OracleIntegrationSuite
[error] 	org.apache.spark.sql.jdbc.OracleIntegrationSuite
  1. pyspark-mllib
Error: The operation was canceled.

@cloud-fan
Copy link
Contributor

can we retrigger the failed test jobs via GitHub UI?

@andylam-db
Copy link
Contributor Author

@cloud-fan Retried, looks like only the Docker integration tests are failing now.

@cloud-fan
Copy link
Contributor

OK that's definitely unrelated. I'm merging it to master, thanks!

@cloud-fan cloud-fan closed this in 8a972c2 Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants