← Back to Pull requests

[python] Reject duplicate columns and unknown or duplicate keys in create_table and alter_table #11028

Closed
unknown closed this pull request without merging on Nov 10, 2026 09:14 UTC
View on GitHub
unknown unknown commented on Nov 07, 2026 08:57 UTC
Author

Purpose

close #11027

create_table accepted a partition or primary key that is not a column, and the persisted table could then no longer be loaded. It also accepted duplicate column names and duplicate keys.

SchemaManager.create_table now checks, as Java's Schema does when it is built, that column names are unique and that partition and primary keys do not repeat and are columns. The messages use Java's wording. FileSystemCatalog and JdbcCatalog create tables through it, so nothing is written for a rejected schema. Existing tables are not checked when they are loaded.

alter_table runs the same checks on the schema it builds, as Java does on every alter. Renaming a primary key twice in one alter (id to middle, then middle to new_id) left primaryKeys = [middle] in the new schema, and the table could no longer be loaded; that alter is now rejected before the schema is written. On an existing table that already has duplicate columns or keys, an alter that leaves the duplicates in place is rejected.

Tests

TestColumnAndKeyValidation in schema_manager_test.py, failing on master:

  • A partition key or primary key that is not a column is rejected, and the table name can still be used.

  • Duplicate column names, partition keys and primary keys are rejected.

  • Renaming the primary key twice in one alter is rejected and the table keeps its key; a single rename of the key, which master also allows, still works.
  • Diff: 182 lines (+136 / -46) across 2 files Reviewer: LuciferYang Review duration: 4337m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 182 lines diff across 2 files
    0.36
    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.312
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11028"
    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: 35.6% (MEDIUM) · Higher = larger blast radius
    35.6%
    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: 14.1% · Safe to merge
    14.1%
    Repository