Skip to content

fix: validate type strings in ColumnDef constructor#78

Merged
zfarrell merged 1 commit intomainfrom
fix/validate-column-def-types
Feb 26, 2026
Merged

fix: validate type strings in ColumnDef constructor#78
zfarrell merged 1 commit intomainfrom
fix/validate-column-def-types

Conversation

@zfarrell
Copy link
Contributor

Summary

Closes #56.

  • ColumnDef::new() now validates the type string by calling ducklake_to_arrow_type() before constructing, returning Result<Self> instead of Self. Invalid or empty type strings are rejected at write time rather than causing confusing errors at read time.
  • ColumnDef fields changed from pub to pub(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() in table_writer.rs simplified to use ColumnDef::from_arrow() directly, removing a redundant arrow_to_ducklake_type + ColumnDef::new round-trip.

Test plan

  • cargo build passes
  • cargo test passes (all 134 unit + integration tests)
  • New tests verify valid types accepted, invalid types rejected, empty strings rejected

… 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.
@zfarrell zfarrell merged commit 3f142f0 into main Feb 26, 2026
4 of 6 checks passed
@zfarrell zfarrell deleted the fix/validate-column-def-types branch February 26, 2026 03:48
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.

ColumnDef accepts invalid type strings without validation

1 participant