Skip to content

[core] Reject empty or whitespace-only column names - #1583

Open
taoran92 wants to merge 2 commits into
apache:mainfrom
taoran92:fix/reject-empty-column-names
Open

taoran92 wants to merge 2 commits into
apache:mainfrom
taoran92:fix/reject-empty-column-names

Conversation

@taoran92

@taoran92 taoran92 commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Purpose

Closes #1582

Reject empty and whitespace-only column names before CREATE or ALTER publishes a schema, while keeping previously saved tables readable and allowing invalid names to be corrected.

Brief change log

  • Validate field names in the shared CREATE/ALTER schema checks, including fields nested in ROW, ARRAY, MAP, and MULTISET types.
  • Validate deserialized schemas at the catalog CREATE entry point as well.
  • Add schema and DataFusion SQL regression tests for rejection, unchanged schemas after failed ALTER, and legacy column renaming.

Tests

  • Schema unit tests, filesystem catalog unit tests, and the DataFusion SQLContext integration suite passed using test binaries rebuilt from this commit with cached Cargo dependencies. SQLContext tests used an increased thread stack.
  • The new SQL regression fails on the parent commit because an empty-name CREATE succeeds, and passes with this change.
  • Existing-data checks confirmed that rejected ALTER leaves schema and files unchanged, and legacy renaming preserves field IDs and row values.
  • cargo fmt --all --check and git diff --check passed.

API and Format

No API signature or storage format changes. CREATE and ALTER now reject blank field names, including nested fields. Reading existing schemas remains unchanged.

ALTER validates the complete resulting schema: a legacy table with multiple invalid names must correct all of them in one ALTER; unrelated ALTERs are rejected until those names are corrected. Batch correction and subsequent reads are covered by the existing-data checks.

Documentation

No documentation changes.

@taoran92
taoran92 marked this pull request as ready for review December 2, 2026 14:53
@taoran92
taoran92 force-pushed the fix/reject-empty-column-names branch from 9ca1442 to 3c4c71b Compare December 3, 2026 03:13

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rejecting blank names prevents Rust from publishing schemas that Java rejects. I ran 5,753 core, DataFusion, and SQLContext tests on 3c4c71be integrated with main 2456fee3. A separate write, commit, read, and ALTER probe reproduced the compatibility regression below.

Comment thread crates/paimon/src/spec/schema.rs Outdated
),
});
}
validate_non_blank_field_names(fields)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Keep unrelated ALTERs available for tables with legacy nested names. I wrote a Parquet row with payload ROW<"" INT> and value 42 on main. Both builds read 42, and updating snapshot.num-retained.max succeeds on main. The same property change on this head returns the new blank-name error. Batched RenameColumn works for top-level names, while the catalog rejects nested rename. An ID-preserving type change through the Rust API recovered the stored value. The existing DataFusion ALTER COLUMN ... SET DATA TYPE STRUCT<value INT> path assigns a new child ID and returned NULL for the stored value in the same test. Please reject newly introduced or renamed blank fields during ALTER and allow unchanged legacy field IDs to pass, so existing tables remain maintainable while users repair their schemas.

@taoran92 taoran92 Dec 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing. I addressed this in new commit. ALTER now allows a legacy blank field name when both the field ID and the name are unchanged. It still rejects adding a field with a blank name or renaming a field to a blank name.

I verified that updating snapshot.num-retained.max succeeds on the legacy table with payload ROW<"" INT> and that the existing Parquet value still reads back as 42. I also verified that correcting the nested name while preserving its field ID keeps the value readable.

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.

Rust catalog accepts empty or whitespace-only column names

2 participants