Skip to content

fix: make odata_describe report the type the reader binds - #256

Closed
jrosskopf wants to merge 1 commit into
fix/254-decimal-facetsfrom
fix/odata-describe-reports-bound-type
Closed

jrosskopf wants to merge 1 commit into
fix/254-decimal-facetsfrom
fix/odata-describe-reports-bound-type

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #254, stacked on #255 (this PR targets that branch, so the diff shows only the describe change; retarget to main once #255 merges).

The defect

odata_describe() mapped the EDM type name alone, through the facet-blind ConvertEdmTypeStringToDuckDbTypeString. That is blind to everything the reader is not:

Property reader binds describe said
Edm.Decimal Scale="18" DECIMAL(38,18) DECIMAL
Edm.Decimal Precision="19" (no Scale) DOUBLE DECIMAL
Collection(Edm.String) VARCHAR[] VARCHAR
a complex type STRUCT(...) VARCHAR

So the one function whose entire job is to answer "what will this column be?" was free to disagree with the answer. It now goes through BuildLogicalTypeForProperty — the same mapping the reader uses.

Facets

The reported precision / scale / max_length had the matching defect: an absent facet was reported as 0, indistinguishable from a declared zero. Scale="0" against an absent Scale is exactly what decides DECIMAL(p,0) against DOUBLE, so the field a caller would consult to understand the type could not express the distinction. An undeclared facet is now NULL.

This is a visible change for anyone reading those three fields — worth noting in the release summary.

Verification

Live, against the public Northwind V4 service (its UnitPrice declares no facets):

-- before: describe said DECIMAL, odata_read bound DOUBLE
-- after:
odata_describe(...Products) -> UnitPrice  DOUBLE  precision=NULL scale=NULL
DESCRIBE SELECT UnitPrice FROM odata_read(...Products) -> UnitPrice  double

New test/cpp/test_odata_describe_types.cpp covers all four shapes plus the absent-vs-zero facet distinction against a local server — there was no C++ coverage of odata_describe at all before. The live test/sql/odata_describe.test still passes unchanged, as does the full suite (3189 assertions / 583 cases).

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

odata_describe() mapped the EDM type NAME alone, which is blind to everything
the reader is not. An Edm.Decimal was described as "DECIMAL" whatever its
Precision/Scale facets said, so a column the reader binds as DECIMAL(38,18) --
or as DOUBLE, when no Scale is declared -- was described as neither. A
Collection(Edm.String) and a complex type were both described as "VARCHAR",
where the reader binds VARCHAR[] and a STRUCT.

The one function whose entire job is to answer "what will this column be?" was
therefore free to disagree with the answer. It now goes through the same
property-aware mapping the reader uses.

The reported facets had the matching defect: an absent Precision/Scale/MaxLength
was reported as 0, indistinguishable from a declared zero -- and Scale="0"
against an absent Scale is exactly what decides DECIMAL(p,0) against DOUBLE. An
undeclared facet is now NULL.

Verified against the live Northwind V4 service, whose UnitPrice declares no
facets: describe said DECIMAL while odata_read bound DOUBLE; both now say DOUBLE.

Follow-up to #254.
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.

1 participant