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-48188][SQL] Consistently use normalized plan for cache #46465

Closed
wants to merge 1 commit into from

Conversation

cloud-fan
Copy link
Contributor

What changes were proposed in this pull request?

We must consistently use normalized plans for cache filling and lookup, or inconsistency will lead to cache misses.

To guarantee this, this PR makes CacheManager the central place to do plan normalization, so that callers don't need to care about it. Now most APIs in CacheManager take either Dataset or LogicalPlan. For Dataset, we get the normalized plan directly. For LogicalPlan, we normalize it before further use.

The caller side should pass Dataset when invoking CacheManager, if it already creates Dataset. This is to reduce the impact, as extra creation of Dataset may have perf issues or introduce unexpected analysis exception.

Why are the changes needed?

Avoid unnecessary cache misses for users who add custom normalization rules

Does this PR introduce any user-facing change?

No, perf only

How was this patch tested?

existing tests

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

no

@github-actions github-actions bot added the SQL label May 8, 2024
@yaooqinn
Copy link
Member

yaooqinn commented May 8, 2024

Thank you @cloud-fan, merged to master

@yaooqinn yaooqinn closed this in 8950add May 8, 2024
JacobZheng0927 pushed a commit to JacobZheng0927/spark that referenced this pull request May 11, 2024
### What changes were proposed in this pull request?

We must consistently use normalized plans for cache filling and lookup, or inconsistency will lead to cache misses.

To guarantee this, this PR makes `CacheManager` the central place to do plan normalization, so that callers don't need to care about it. Now most APIs in `CacheManager` take either `Dataset` or `LogicalPlan`. For `Dataset`, we get the normalized plan directly. For `LogicalPlan`, we normalize it before further use.

The caller side should pass `Dataset` when invoking `CacheManager`, if it already creates `Dataset`. This is to reduce the impact, as extra creation of `Dataset` may have perf issues or introduce unexpected analysis exception.

### Why are the changes needed?

Avoid unnecessary cache misses for users who add custom normalization rules

### Does this PR introduce _any_ user-facing change?

No, perf only

### How was this patch tested?

existing tests

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

no

Closes apache#46465 from cloud-fan/cache.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Kent Yao <yao@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants