Skip to content

feat: implement variant_length UDF - #61

Open
getChan wants to merge 3 commits into
datafusion-contrib:mainfrom
getChan:feat/variant-length
Open

feat: implement variant_length UDF#61
getChan wants to merge 3 commits into
datafusion-contrib:mainfrom
getChan:feat/variant-length

Conversation

@getChan

@getChan getChan commented May 22, 2026

Copy link
Copy Markdown
Contributor

Closes #41

Summary

Implements variant_length(VariantArray, path) as described in #41.

Returns the number of elements in a Variant Array or Object at the given path. Returns NULL for non-array/object variants (e.g. primitives) or NULL inputs.

Return type

UInt64 (Nullable)

Behavior

Input Result
[1, 2, 3] at "" 3
{"a": 1, "b": 2} at "" 2
{"a": [1,2,3,4]} at "a" 4
42 (primitive) NULL
NULL variant NULL

Tests

5 unit tests covering scalar array, scalar object, nested path, primitive→NULL, and columnar input.

@getChan
getChan force-pushed the feat/variant-length branch 2 times, most recently from 6e46ba7 to 36ac068 Compare May 22, 2026 04:02
@getChan
getChan marked this pull request as draft May 22, 2026 04:03
@friendlymatthew

Copy link
Copy Markdown
Member

Hi @getChan is this ready for a review?

@getChan
getChan marked this pull request as ready for review June 10, 2026 07:27
@getChan

getChan commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@friendlymatthew Added sqlogictests. Ready for review!

@friendlymatthew friendlymatthew left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, we just recently pushed a PR that bumps deps. You may want to rebase

getChan and others added 3 commits June 10, 2026 16:55
Closes datafusion-contrib#41

Returns the number of elements in a Variant Array or Object at the
given path. Returns NULL for non-array/object variants or NULL inputs.

- variant_length(VariantArray, path) -> UInt64 (Nullable)
- Supports scalar and columnar variant inputs with scalar path
- 5 unit tests covering array, object, nested path, primitive->NULL, columnar
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@getChan
getChan force-pushed the feat/variant-length branch from b6c4e5d to 12caa5e Compare June 10, 2026 08:04
@getChan

getChan commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebased. Some tests are failing, but they are outside the scope of this PR.

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.

variant_length: Initial implementation

2 participants