apache / apache/datafusion-comet

[Variant] Support top-level VariantType in Comet MapInArrow and MapInPandas transport

Offen
#5,437 1 Kommentar 0 Reaktionen 1 zugewiesene Person Beansprucht von @peterxcli Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Scala
Sterne
1.3k
Forks
375
Ø Merge
2 T. 10 Std.
Gemergte PRs (30 T.)
231

Beschreibung

### What is the problem the feature request solves?

Spark 4.1 supports top-level Variant values through Arrow Python transport. Its JVM Arrow bridge maps Variant to a `Struct` and marks the metadata child ([ArrowUtils](https://github.com/apache/spark/blob/v4.1.3/sql/api/src/main/scala/org/apache/spark/sql/util/ArrowUtils.scala#L183-L197)); PySpark converts that shape to and from `VariantVal` ([PySpark Arrow conversion](https://github.com/apache/spark/blob/v4.1.3/python/pyspark/sql/pandas/types.py#L201-L208), [Variant value conversion](https://github.com/apache/spark/blob/v4.1.3/python/pyspark/sql/pandas/types.py#L1157-L1171)).

Comet currently excludes any Variant-bearing input or output from its accelerated MapInArrow/MapInPandas rewrite in [`EliminateRedundantTransitions`](https://github.com/peterxcli/datafusion-comet/blob/c355fefd9c0b7e96d86523a7214bb2cdd47e1a55/spark/src/main/scala/org/apache/comet/rules/EliminateRedundantTransitions.scala#L203-L213). This is a safe fallback, but it leaves the Python batch transport capability untracked.

### Describe the potential solution

- Support direct, top-level Variant inputs and outputs in Comet MapInArrow and MapInPandas operators.
- Translate only at the Python boundary between Comet's canonical parent `arrow.parquet.variant` marker and Spark/PyArrow's Variant child marker.
- Preserve exact `[value, metadata]` order, Binary children, field names, SQL-null parent bitmap, Variant JSON null, and zero-row streams in both directions.
- Reject malformed layouts and retain fallback for nested Variant or unsupported Python operator families.

Add parity and plan tests for MapInArrow and MapInPandas identity functions, projected fields around Variant, nullable values, and Python-produced Variant output. Verify Spark receives `VariantType`, not an ordinary Struct.

### Additional context

#5386 tracks scalar Arrow Python UDF expansion and #5123 tracks grouped/window/apply operators generally; neither specifies Variant's logical metadata and layout. #5407 and #5425 define the canonical Comet-side Field contract.

Nested Variant and the other Python operator families remain separate until explicitly supported.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.