Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow safe numeric widening in Substrait schema compatibility checks#20646

Open
N-Boutaib wants to merge 2 commits intoapache:mainfrom
N-Boutaib:main
Open

Allow safe numeric widening in Substrait schema compatibility checks#20646
N-Boutaib wants to merge 2 commits intoapache:mainfrom
N-Boutaib:main

Conversation

@N-Boutaib
Copy link

@N-Boutaib N-Boutaib commented Mar 2, 2026

Which issue does this PR close?

  • Closes None.

Rationale for this change

ensure_field_compatibility rejects Substrait plans where the base_schema declares a wider numeric type than the table's actual schema (e.g., Int64 in the plan vs Int32 in the table), even though the widening is lossless. This forces consumers to re-implement read_with_schema without the check or artificially widen types in the catalog provider.

This commonly occurs when an upstream Substrait producer normalizes all numerics to a wider type, while the native catalog preserves the original precision.

What changes are included in this PR?

Adds is_safe_widening to accept lossless numeric promotions (signed/unsigned integers, floats).
Modifies ensure_field_compatibility to allow fields where the table type can be safely widened to the plan type.

Are these changes tested?

Yes, unit tests for is_safe_widening with widened types.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the substrait Changes to the substrait crate label Mar 2, 2026
@N-Boutaib N-Boutaib marked this pull request as ready for review March 2, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant