fix: widen Edm.Decimal facets that leave no integral digits - #255
Merged
Merged
Conversation
A TOPdesk reporting service publishes every money column as Edm.Decimal with a declared Scale and no Precision. An absent Precision is unbounded in CSDL, but BuildDecimalLogicalType defaulted it to 18, so Scale="18" produced DECIMAL(18,18) -- eighteen fractional digits with no room for a single integral one. Every value of 1 or more then failed to cast and was returned as NULL with a conversion warning. The same degenerate type came out of a declared Precision <= Scale, because the scale was truncated down to the precision rather than the precision widened. Both now widen to DuckDB's maximum of 38, keeping the scale the service declared about its own data. A scale too wide for any DuckDB DECIMAL falls back to DOUBLE, as an absent or "variable" scale already did. No mapping that works today is narrowed. Covered by a unit case over the facet matrix and by an end-to-end case that reproduces the report through ATTACH and odata_read against a local server, with only the remote service stubbed. Fixes #254
This was referenced Sep 23, 2026
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.
Fixes #254.
The defect
A TOPdesk reporting service publishes every money column as
Edm.Decimalwith a declaredScaleand noPrecision. An absentPrecisionis unbounded in CSDL, butBuildDecimalLogicalTypedefaulted it to18, soScale="18"producedDECIMAL(18,18)— eighteen fractional digits with no room for a single integral one. Every value of 1 or more then failed to cast and came back NULL:The same degenerate type also came out of a declared
Precision <= Scale, because the scale was truncated down to the precision rather than the precision widened. Both shapes are fixed, so the fix does not depend on which one the service emits.The rule
Scaleabsent or"variable"Scale="18", noPrecisionDECIMAL(18,18)DECIMAL(38,18)Precision="18" Scale="18"DECIMAL(18,18)DECIMAL(38,18)Precision="5" Scale="10"DECIMAL(5,5)DECIMAL(38,10)Precision="13" Scale="3"DECIMAL(13,3)Precision="47" Scale="2"DECIMAL(38,2)Precision="19" Scale="0"DECIMAL(19,0)Scale >= 38DECIMAL(38,38)No mapping that works today is narrowed; only the degenerate ones widen, and only a scale too wide for any DuckDB DECIMAL falls back to DOUBLE.
Tests
test/cpp/test_odata_edm.cpp— the facet matrix above, including a tinyxml2 parse of the reported CSDL shape.test/cpp/test_odata_server_e2e.cpp— an end-to-end case againstODataTestServer: real metadata parsing, real catalog, real JSON conversion, only the remote service stubbed. It reproduces the report through bothATTACH ... (TYPE odata)(the reporter's ownSELECT DISTINCT) andodata_read(), and before the fix it failed with the exact warning quoted above.erpl_web_tests: 3146 assertions in 582 cases, all green. SQLLogicTests: all green.Docs are updated in a companion PR on the landing page (Type Mapping + a Troubleshooting entry).
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.