Skip to content

Spark 4.1: Test geometry and geography DML and fall back from vectorized reads#17149

Open
huan233usc wants to merge 4 commits into
apache:mainfrom
huan233usc:geo-spark-dml
Open

Spark 4.1: Test geometry and geography DML and fall back from vectorized reads#17149
huan233usc wants to merge 4 commits into
apache:mainfrom
huan233usc:geo-spark-dml

Conversation

@huan233usc

Copy link
Copy Markdown
Contributor

Adds end-to-end Spark SQL DML tests for geometry and geography columns, and
fixes a vectorized-read bug those tests surfaced. This completes the Phase-1
geo end-to-end item (row-level DML with deletion vectors / nested geo / nulls)
and builds on #17073 (Spark geo value path) and #16982 (Parquet geo WKB values).

Tests

TestSparkGeospatial previously covered only INSERTSELECT read-back. This
adds row-level DML on a geo table under merge-on-read + format version 3
(deletion vectors):

  • testDeleteGeospatialMergeOnReadDELETE leaves a survivor in a single data
    file, and the snapshot summary confirms a deletion vector was written
    (added-dvs = 1); the surviving null-geo row round-trips.
  • testUpdateGeospatialMergeOnReadUPDATE swaps a row's geometry; others
    unchanged.
  • testMergeGeospatialMergeOnReadMERGE updates a matched row and inserts a
    not-matched row, both carrying geo values.
  • testDeleteNestedGeometryMergeOnRead — geometry nested in a STRUCT; delete by
    a nested non-geo field, surviving nested geometry (and a null nested geometry)
    still round-trip.

Geo values are asserted via hex(st_asbinary(...)) round-trips and DML filters on
non-geo columns, since Spark 4.1 has no spatial predicates.

Vectorization fallback (production fix)

geometry/geography are primitive types, so they passed
SparkBatch.supportsParquetBatchReads(NestedField) and were routed to the
vectorized Parquet reader — but there is no Arrow geo vector yet, so scanning a geo
column with vectorization enabled threw
UnsupportedOperationException: Unsupported primitive type: geometry. This excludes
the two geo types from vectorized reads so they fall back to the row-based reader.

With this fix, testGeospatialWkbReadBack now runs (no longer skipped) with
vectorization both off and on, proving the fallback. A dedicated Arrow geo
vector remains future work.

…zed reads

Add end-to-end DELETE/UPDATE/MERGE tests for geometry and geography columns
under merge-on-read at format version 3, covering deletion vectors, nested geo
in a struct, and null values.

Geometry and geography are primitive types, so they slipped through the
vectorized Parquet read gate in SparkBatch even though there is no Arrow geo
vector yet, which threw when scanning geo columns with vectorization enabled.
Exclude the two geo types so they fall back to the non-vectorized reader.
@github-actions github-actions Bot added the spark label Jul 9, 2026
Xin Huang added 3 commits July 9, 2026 14:47
Select the delete snapshot by operation instead of the latest committed_at,
whose millisecond granularity could tie with the insert snapshot, and give the
test its own table so there is exactly one delete snapshot to inspect.
Copy-on-write is the default row-level mode, and its rewrite path reads geo
values back out of the surviving data files, so add DELETE and UPDATE tests
that exercise it (the merge-on-read tests only cover deletion vectors).
Fold the duplicated merge-on-read and copy-on-write DELETE and UPDATE variants
into single tests parametrized over the write mode, and run MERGE and the nested
delete over both modes too. The deletion-vector assertion applies only to
merge-on-read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant