Skip to content

[Variant] Track and remove native Variant compatibility workarounds after upstream fixes #5477

Description

@peterxcli

What is the problem the feature request solves?

Native Variant projection from #5407, continued by #5868, includes compatibility paths for gaps in upstream Variant compute, Spark-compatible Parquet reader policy, and older Spark Variant encodings. As of 2026-09-13, Comet main locks DataFusion 55.1.0 and Arrow/Parquet 59.3.0; #5868 currently locks DataFusion 55.0.0 and Arrow/Parquet 59.3.0. The dependency upgrade is no longer a blocker. These paths are intentionally narrow, but some perform row-by-row decoding or metadata rebuilding and should not become permanent accidentally.

This issue records exactly which code is removable after an upstream fix ships, which upstream change owns it, and which nearby code is required Comet/Spark integration and must remain.

This is maintenance follow-up for #5407 under the Native Variant epic #5438. Spark UTF-16 output cleanup is tracked separately by #5474. Unicode case-insensitive Parquet field matching (#5495) is complete through #5602. The split series in #5546 reuses that shared matcher and does not carry the original PR's Unicode guards.

Arrow-rs compute workarounds

DataFusion/Arrow reader integration workaround

  • Use Spark-compatible physical schema inference for projected Variant scans
    • Spark ignores the advisory ARROW:schema footer hint, while Arrow-rs honors it and can restore shredded leaves as Decimal256, Date64, Dictionary, or fixed-size types. Comet therefore replaces an embedded hint with physical Parquet inference for an unencrypted scan whose pruned required schema projects Variant.
    • Arrow-rs also maps physical Parquet ENUM to Binary, while Spark maps ENUM to String. Once Arrow inference has discarded that annotation, the Variant normalizer cannot distinguish ENUM from raw BINARY. Comet therefore adds back a physical-schema-derived hint that changes only ENUM leaves to Utf8 (ENUM mapping, footer rewrite). Runtime controls verify ENUM and STRING become Variant strings while unannotated BINARY remains binary.
    • All other key/value metadata, row groups, column orders, column indexes, and offset indexes are preserved. Using the pruned schema also preserves feat: Support native scans with unprojected Spark 4 VARIANT columns #5377: an unread Variant column does not activate this path. Encrypted Variant scans remain on Spark because reconstructing public FileMetaData cannot preserve arrow-rs's private decryptor state.
    • Reassessment: merged Allow specifying an arrow schema for PartitionedFile datafusion#22360 already supplies PartitionedFile.arrow_schema. Arrow's ArrowReaderOptions::with_schema suppresses advisory Arrow metadata and accepts nested Binary-to-Utf8 hints. A local check verified ENUM-to-Utf8, raw BINARY preservation, bypass of an invalid Arrow hint, and reuse of the original metadata Arc. No additional Arrow ENUM-conversion API is needed for a known full per-file schema.
    • Remaining upstream integration request: Allow deriving a Parquet file Arrow schema from metadata during lazy opening datafusion#25251. Comet learns each file's shredded layout during lazy footer loading; the current reader factory cannot return a newly derived schema/options to DataFusion's opener. Allow source-specific physical-schema policy after footer loading and before Arrow schema inference, preserving the original metadata, cache behavior and decryption state. #22360 is sufficient when that complete schema is already available before opening.
    • Parquet schema file type coercion functionality is not applied on all fields in nested schemas, only on the top-level fields datafusion#25192 covers nested table-schema coercions; it does not supply missing per-file shredded layouts or physical ENUM annotations.
    • Remove the footer reconstruction when the existing supplied-schema route can be used at Comet's lazy-open boundary. Reassess the encrypted fallback only after encryption-specific validation; preserving the metadata Arc alone is not an encrypted-scan test.

Describe the potential solution

For each checklist item:

  1. Wait for the relevant upstream behavior to merge and appear in a released dependency or reachable DataFusion reader API.
  2. Upgrade Arrow/Parquet/DataFusion through the normal dependency update.
  3. Delete only the mapped compatibility branch; do not duplicate an upstream implementation locally.
  4. Keep or adapt the existing regression tests to prove the upstream path works through Comet.
  5. Run the focused Rust Variant tests, Spark 4 Variant SQL tests, Spark 3 compilation boundary, formatting/lint, and git diff --check.

Definition of done:

  • Every temporary upstream workaround is either removed or explicitly retained with a current compatibility reason.
  • Encoded metadata, the chosen encoded-child policy, empty object keys, missing shredded-key compatibility, wide decimals, the chosen unsigned-input policy, and physical-schema inference remain covered.
  • Whole-value Variant projection still returns Spark's required [value, metadata] layout and preserves SQL NULL versus Variant JSON null.
  • Unread Variant pruning remains native, and encrypted scans do not lose encryption state.
  • No Spark/FFI integration code is removed merely because an Arrow-rs dependency was upgraded.

Additional context

The following nearby code is not covered by the upstream fixes above:

Dependency snapshot (2026-09-13): Comet main locks DataFusion 55.1.0 and Arrow/Parquet 59.3.0; #5868 locks DataFusion 55.0.0 and Arrow/Parquet 59.3.0. Links to the original #5407 implementation describe the compatibility branches to reassess, not the current main dependency. Checked upstream-fix entries do not by themselves mean Comet's released dependency contains the fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:scanParquet scan / data readingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions