Skip to content

[spark] Fix view resolution for CTE and ORDER BY ordinal#7552

Merged
JingsongLi merged 1 commit intoapache:masterfrom
Zouxxyy:dev/spark-fix-view
Mar 31, 2026
Merged

[spark] Fix view resolution for CTE and ORDER BY ordinal#7552
JingsongLi merged 1 commit intoapache:masterfrom
Zouxxyy:dev/spark-fix-view

Conversation

@Zouxxyy
Copy link
Copy Markdown
Contributor

@Zouxxyy Zouxxyy commented Mar 30, 2026

Purpose

Fix PaimonViewResolver to apply early analysis rules (CTESubstitution, SubstituteUnresolvedOrdinals) to parsed view plans. These rules run in Spark's earlyBatches before the Resolution batch, so they won't re-run for plans injected by PaimonViewResolver during resolution.

Without this fix:

  • Views with CTE (WITH t AS ...) fail with TABLE_OR_VIEW_NOT_FOUND
  • Views with ORDER BY 1 (ordinal) produce incorrect results

Tests

Add tests in PaimonViewTestBase:

  • Paimon View: create view with CTE
  • Paimon View: create view with ORDER BY ordinal

Copy link
Copy Markdown
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi JingsongLi merged commit d312694 into apache:master Mar 31, 2026
12 checks passed
XiaoHongbo-Hope pushed a commit that referenced this pull request Apr 1, 2026
Fix PaimonViewResolver to apply early analysis rules (CTESubstitution,
SubstituteUnresolvedOrdinals) to parsed view plans. These rules run in
Spark's earlyBatches before the Resolution batch, so they won't re-run
for plans injected by PaimonViewResolver during resolution.

Without this fix:
- Views with CTE (`WITH t AS ...`) fail with `TABLE_OR_VIEW_NOT_FOUND`
- Views with `ORDER BY 1` (ordinal) produce incorrect results
XiaoHongbo-Hope pushed a commit that referenced this pull request Apr 1, 2026
Fix PaimonViewResolver to apply early analysis rules (CTESubstitution,
SubstituteUnresolvedOrdinals) to parsed view plans. These rules run in
Spark's earlyBatches before the Resolution batch, so they won't re-run
for plans injected by PaimonViewResolver during resolution.

Without this fix:
- Views with CTE (`WITH t AS ...`) fail with `TABLE_OR_VIEW_NOT_FOUND`
- Views with `ORDER BY 1` (ordinal) produce incorrect results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants