fix(rust): raise schema mismatch when decimal is not subset #2330
+65
−8
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.
Description
The
can_cast_types
is a bit to flexible with decimals, since we define the decimal type in the table metadata. So if the source data contains a decimal that is larger than the decimal in the table metadata, we should throw an error. Before we would let our writer just write becausecan_cast_types
does not check precision and scale for casting so Decimal(30.1) could be written after the table was set to only allow precision=1, scale=1.After the write, the json parser would not be able to read the table anymore since it throws a decimal overflow, and rightfully so. This fix will prevent tables to get in these invalid states.