fix: validate type strings in ColumnDef constructor#78
Merged
Conversation
… types early Change ColumnDef::new() to return Result<Self> and validate the ducklake_type string by calling ducklake_to_arrow_type() before constructing. This catches invalid type strings at write time rather than deferring the error to read time, where it would surface as a confusing failure. Make ColumnDef fields pub(crate) instead of pub to prevent bypassing validation via struct literal construction. Add public getter methods (name(), ducklake_type(), is_nullable()) for external consumers. Simplify arrow_schema_to_column_defs() in table_writer.rs to use ColumnDef::from_arrow() directly, removing the redundant arrow_to_ducklake_type + ColumnDef::new round-trip. Update all call sites to handle the Result, and add tests verifying that valid types are accepted while invalid and empty types are rejected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #56.
ColumnDef::new()now validates the type string by callingducklake_to_arrow_type()before constructing, returningResult<Self>instead ofSelf. Invalid or empty type strings are rejected at write time rather than causing confusing errors at read time.ColumnDeffields changed frompubtopub(crate)to prevent bypassing validation via struct literal construction. Public getter methods (name(),ducklake_type(),is_nullable()) added for external consumers.arrow_schema_to_column_defs()intable_writer.rssimplified to useColumnDef::from_arrow()directly, removing a redundantarrow_to_ducklake_type+ColumnDef::newround-trip.Test plan
cargo buildpassescargo testpasses (all 134 unit + integration tests)