fix: normalize type aliases and add promotion rules for schema evolution#82
Open
fix: normalize type aliases and add promotion rules for schema evolution#82
Conversation
- Add normalize_ducklake_type() for canonical type resolution (int/integer/INT all -> int32) - Add is_promotable() for safe type widening (int->bigint, float->double, timestamp->timestamptz) - Add types_compatible() combining normalization + promotion for schema evolution checks - Replace exact string equality with types_compatible() in schema evolution Found during Feb 2026 security review Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous check (tp >= fp && ts >= fs) allowed promotions like decimal(10,2) → decimal(12,8) where the integer part shrinks from 8 to 4 digits, potentially causing overflow. Now checks that both integer digits (precision - scale) and fractional digits don't shrink.
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
normalize_ducklake_type()to convert type aliases to canonical forms (e.g., "int" -> "int32", "text" -> "varchar")is_promotable()with safe type widening rules: integer widening, float widening, int-to-float64, timestamp-to-timestamptz, decimal precision wideningtypes_compatible()that checks alias equivalence and promotion for schema evolutiontypes_compatible()so that e.g. a table with "int" columns can accept "int32" data without errorTest plan
normalize_ducklake_type()across all alias families (int, bigint, string, float, double, bool, smallint, tinyint)is_promotable()covering signed/unsigned widening, float widening, int-to-float, timestamp promotion, decimal widening, and rejection of narrowing/incompatible typestypes_compatible()covering alias equivalence, case insensitivity, promotion, and incompatible typescargo testpasses