Open
Conversation
Adds a new introspection function that returns a struct containing the complete Arrow Field information for any expression: name, data_type, nullable, and metadata. This unifies what `arrow_typeof`, `arrow_metadata`, and `is_nullable` provide individually. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
martin-g
reviewed
Apr 6, 2026
| query ? | ||
| SELECT arrow_field(ARRAY[1,2,3]) | ||
| ---- | ||
| {name: lit, data_type: List(Int64), nullable: false, metadata: {}} |
Member
There was a problem hiding this comment.
It would be good to have tests for more complex types like Map and Struct too! Maybe a Dictionary too.
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Member
|
My suggestions broke the build :-/ Sorry! |
Contributor
Author
|
no worries @martin-g, fixed now! |
4 tasks
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.
Which issue does this PR close?
Rationale for this change
DataFusion has individual introspection functions (
arrow_typeof,arrow_metadata,is_nullable) but no single function that returns the complete ArrowFieldrepresentation. Havingarrow_field(expr)that returns a struct with all field info avoids multiple function calls when you need the full picture, and provides a natural complement to the existing introspection suite.What changes are included in this PR?
Adds
arrow_field(expr)scalar UDF that returns a struct:The returned struct has four fields:
name(Utf8) — the field namedata_type(Utf8) — the Arrow data type as stringnullable(Boolean) — whether the field is nullablemetadata(Map<Utf8, Utf8>) — the field metadataIndividual fields are accessible via bracket syntax.
Files:
datafusion/functions/src/core/arrow_field.rs— new UDF implementationdatafusion/functions/src/core/mod.rs— registrationdatafusion/sqllogictest/test_files/arrow_field.slt— testsAre these changes tested?
Yes, sqllogictest covering literals (int, null, bool, string, float, list), table columns, nullability, and struct field access.
Are there any user-facing changes?
New SQL function
arrow_field(expr)is available.🤖 Generated with Claude Code