This is an automated email from the ASF dual-hosted git repository. wenchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 94666e9cd63a [SPARK-45421][SQL] Catch AnalysisException over InlineCTE 94666e9cd63a is described below commit 94666e9cd63a9471f50ab2fce6c8439c8fd74154 Author: Rui Wang <rui.w...@databricks.com> AuthorDate: Fri Oct 6 10:48:24 2023 +0800 [SPARK-45421][SQL] Catch AnalysisException over InlineCTE ### What changes were proposed in this pull request? We are catching exceptions for `CheckAnalysis` and attach inlined plan. However, if `InlineCTE` itself throws we can also catch but attach original plan. ### Why are the changes needed? Attach original plan if `InlineCTE` throws. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT ### Was this patch authored or co-authored using generative AI tooling? NO Closes #43227 from amaliujia/inline_cte_plan. Authored-by: Rui Wang <rui.w...@databricks.com> Signed-off-by: Wenchen Fan <wenc...@databricks.com> --- .../apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 64f1cafd03fe..81ca59c0976e 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -164,12 +164,18 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB } // Inline all CTEs in the plan to help check query plan structures in subqueries. - val inlinedPlan = inlineCTE(plan) + var inlinedPlan: Option[LogicalPlan] = None try { - checkAnalysis0(inlinedPlan) + inlinedPlan = Some(inlineCTE(plan)) } catch { case e: AnalysisException => - throw new ExtendedAnalysisException(e, inlinedPlan) + throw new ExtendedAnalysisException(e, plan) + } + try { + checkAnalysis0(inlinedPlan.get) + } catch { + case e: AnalysisException => + throw new ExtendedAnalysisException(e, inlinedPlan.get) } plan.setAnalyzed() } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org