adriangb opened a new pull request, #21389:
URL: https://github.com/apache/datafusion/pull/21389

   ## Which issue does this PR close?
   
   - Related to #21387 and #19435
   
   ## Rationale for this change
   
   DataFusion has individual introspection functions (`arrow_typeof`, 
`arrow_metadata`, `is_nullable`) but no single function that returns the 
complete Arrow `Field` representation. Having `arrow_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:
   
   ```sql
   > SELECT arrow_field(x) FROM my_table;
   {name: x, data_type: Int32, nullable: false, metadata: {}}
   
   > SELECT arrow_field(x)['data_type'] FROM my_table;
   Int32
   ```
   
   The returned struct has four fields:
   - `name` (Utf8) — the field name
   - `data_type` (Utf8) — the Arrow data type as string
   - `nullable` (Boolean) — whether the field is nullable
   - `metadata` (Map<Utf8, Utf8>) — the field metadata
   
   Individual fields are accessible via bracket syntax.
   
   **Files:**
   - `datafusion/functions/src/core/arrow_field.rs` — new UDF implementation
   - `datafusion/functions/src/core/mod.rs` — registration
   - `datafusion/sqllogictest/test_files/arrow_field.slt` — tests
   
   ## Are 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](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to