← Back to Pull requests

[SPARK-56605][SQL] Wire resolution engine to use SQL PATH for table, function, and variable lookup #55523

Closed
unknown closed this pull request without merging on Apr 28, 2026 16:44 UTC
View on GitHub
unknown unknown commented on Apr 23, 2026 20:45 UTC
Author

What changes were proposed in this pull request?

Switch the resolution engine from the legacy single-schema resolutionSearchPath to sqlResolutionPathEntries on CatalogManager, so that SET PATH actually affects how unqualified table names, function names, and variables are resolved.

CatalogManager (CatalogManager.scala):

  • sqlResolutionPathEntries: ordered path entries for resolving unqualified names. When PATH is enabled and set, uses the stored session path; otherwise falls back to defaultPathOrder (legacy).

  • sessionScopeUnqualifiedAllowed: gates unqualified variable access when system.session is not on the PATH.
  • Relation resolution (RelationResolution.scala):

  • relationResolutionEntries / relationResolutionSteps replace relationResolutionSearchPath.

  • PersistentCatalogStep carries the catalog/namespace prefix so each path entry qualifies the object name under that entry.
  • Function resolution (FunctionResolution.scala):

  • sqlResolutionPathEntriesForAnalysis provides candidates for unqualified function names.

  • Procedure resolution (resolveProcedure) moved here from Analyzer.
  • Error context (CheckAnalysis.scala):

  • catalogPathForError now consults AnalysisContext.catalogAndNamespace when inside a view body, so error messages report the view's defining catalog/namespace.

  • UnresolvedTableOrViewSearchPathMode enum controls DDL vs query-like error paths.

  • Uses CatalogManager constants instead of string literals.

  • RelationChanges errors now include the search path.
  • Variable resolution (VariableResolution.scala + callers):

  • allowUnqualifiedSessionTempVariableLookup gates unqualified variable access when system.session is not on the PATH.
  • Analyzer (Analyzer.scala):

  • sessionConf constructor parameter for isolated analysis (e.g. Connect).

  • resolutionConf for path-based resolution.

  • AnalysisContext.resolutionPathEntries field (initially None; frozen path wiring comes in follow-up PR).
  • Single-pass resolver: Resolver, HybridAnalyzer, NameScope, ResolverGuard aligned with new resolution signatures.

    Frozen path analysis for views/SQL functions (using stored path during analysis) comes in a follow-up PR. This PR only wires the resolution engine to use the live session path.

    Why are the changes needed?

    SET PATH (merged in SPARK-56501) stores the session path but the resolvers still used the legacy single-schema path. This PR completes the wiring so PATH actually affects resolution.

    Part of SPARK-54810.

    Does this PR introduce _any_ user-facing change?

    Yes. With spark.sql.path.enabled = true and SET PATH, unqualified table names, function names, and variable references now resolve according to the stored path order.

    How was this patch tested?

    CI. ProtoToParsedPlanTestSuite updated with analyzer isolation conf. Connect .explain golden files updated. PlanResolutionSuite, NameScopeSuite, TimezoneAwareExpressionResolverSuite updated for new constructor signatures.

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

    Generated-by: Claude Opus 4.6

    Diff: 406 lines (+304 / -102) across 5 files Reviewer: vladimirg-db Review duration: 6958m
    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 · 406 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #55523"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%
    Repository