Skip to content

Cherry-pick apache/datafusion#25015 - #178

Merged
gabotechs merged 1 commit into
branch-54from
jorge.morais/cherry-pick/apache-pr-25015-20260908
Sep 8, 2026
Merged

gabotechs merged 1 commit into
branch-54from
jorge.morais/cherry-pick/apache-pr-25015-20260908

Conversation

@moraistejerina

Copy link
Copy Markdown

cherry-picks apache#25015 (merged as d682553)

Adds SubstraitConsumer::consume_type_metadata(&Type), an extension point letting a consumer attach Arrow field metadata to a Substrait type Arrow can't natively represent (e.g. our json/group/inet user-defined types), applied via a single attach point (substrait_type_to_field) so nested types (list/map/struct) keep metadata too.

Replaces #176, which manually recreated this change before the upstream PR was merged.

…r-defined types (apache#25015)

## Which issue does this PR close?

N/A

## Rationale for this change

`consume_user_defined_type` maps a Substrait user-defined type straight
to a bare `DataType`, so a consumer has no way to mark the resulting
`Field` for a downstream reader to recover semantic type lost in that
mapping. For example, a UDT representing JSON is commonly mapped to
plain `Utf8`, which is then indistinguishable from a real string column
once it reaches a consumer that only sees the Arrow schema (e.g. over
Arrow Flight, with no access to the original plan).

## What changes are included in this PR?

- Adds `consume_user_defined_type_metadata`, a second, additive
extension point on `SubstraitConsumer` defaulting to `Ok(None)`.
- Applies its result to the `Field` built in
`from_substrait_struct_type`, via `Field::with_metadata`.
- Existing consumers are unaffected: the default keeps today's behavior
exactly (no metadata attached).

## Are these changes tested?

Yes, two new unit tests: a consumer that supplies metadata for a
`UserDefined` field gets it attached to the field (data type unchanged),
and a consumer returning `None` (the default) attaches nothing.

## Are there any user-facing changes?

No behavior change for existing consumers. This is a new, optional trait
method with a default implementation.

(cherry picked from commit d682553)
@gabotechs
gabotechs merged commit b41aefa into branch-54 Sep 8, 2026
63 checks passed
@gabotechs
gabotechs deleted the jorge.morais/cherry-pick/apache-pr-25015-20260908 branch September 8, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants