[SPARK-58933][SQL][FOLLOWUP] Keep InsertIntoStatement as the parsed plan for static INSERT targets #59750
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 417 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.361
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #59750"
general
weight: 0.35
cloud-fan
What changes were proposed in this pull request?
This is a follow-up to #58378 that partially reverts it. The parser again produces
InsertIntoStatementfor static and literalIDENTIFIER('...')INSERT targets. The temporaryUnresolvedInsertnode is used only for a non-literalIDENTIFIER(expr)target, as introduced by #58204. Parser-level consumers (SQL statement classification,parse_sql, and pipeline flow registration) handle both shapes again.These parts of #58378 are kept:
Early resolution of a dynamic INSERT target runs inside the analysis planning tracker, and its failures are reported through
QueryPlanningTracker.setAnalysisFailed.The
parse_sqlCTE-shadow exemption stays limited to INSERT targets, so CTE-shadowed DELETE, UPDATE, and MERGE targets are not reported as catalog target tables. The exemption now applies to theInsertIntoStatementtarget, soWITH t AS (...) INSERT INTO t ...still reportstas a target.In addition,
CheckAnalysisraises an internal error if anUnresolvedInsertreaches it without being lowered toInsertIntoStatement.This should be merged to master and branch-4.x, where #58378 landed. branch-4.3 has #58204 but not #58378, so it already has the restored behavior.
Why are the changes needed?
InsertIntoStatementis the parsed INSERT plan that existing parser-level consumers, extensions, and plan-based tooling match on. Only a dynamicIDENTIFIERtarget needs analyzer traversal of the target before the INSERT can be lowered. Parsing every INSERT asUnresolvedInsertforces all of these consumers to handle a new intermediate node for the common static case, without any benefit for that case. Scoping the temporary node to dynamic targets keeps the plan-shape change limited to the statements that need it.Does this PR introduce _any_ user-facing change?
No change relative to a released Spark version. Within unreleased master and branch-4.x, the parsed plan of a static-target INSERT (for example, in
EXPLAIN EXTENDED) showsInsertIntoStatementagain, as in branch-4.3.How was this patch tested?
Updated the existing tests and golden files to the restored plan shape, and added tests for the parsed shape of a literal
IDENTIFIER('...')target and for theCheckAnalysisinvariant check. Then ran:All tests passed.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Isaac (Claude Opus 5.5)
This pull request and its description were written by Isaac.