Skip to content

Conversation

@AngersZhuuuu
Copy link
Contributor

@AngersZhuuuu AngersZhuuuu commented Dec 5, 2025

What changes were proposed in this pull request?

Reopen #44767
Cache Table with CTE won't work, there are two reasons

  1. In the current code CTE in CacheTableAsSelect will be inlined
  2. CTERelation Ref and Def didn't handle the CTEId doCanonicalize issue
    Cause the current case can't be matched.

Why are the changes needed?

Fix Bug

Does this PR introduce any user-facing change?

Yea, Cache table with CTE can work after this pr

For added cache.sql final query
EXPLAIN EXTENDED SELECT * FROM cache_nested_cte_table;

Before this pr, the plan as below, cache won't work.
截屏2025-12-05 11 22 05

After this pr
截屏2025-12-05 11 32 38

How was this patch tested?

Added UT

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

No

@github-actions github-actions bot added the SQL label Dec 5, 2025
@AngersZhuuuu
Copy link
Contributor Author

@cloud-fan Could you take a look again? in #44767 you approved but not merge this pr.
This bug really impact product job's performance

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.

1 participant