Repository navigation
[GH-3560] Read the X and Y bounds of a GeoParquet bbox that has Z or M bounds - #3561
Merged
Merged
Conversation
… Z or M bounds The bbox of a geometry column lists the minimum of every dimension and then the maximum of every dimension: four values for XY, six for XYZ and eight for XYZM. The spatial filter read positions 0 to 3 as xmin, ymin, xmax and ymax, so it took zmin for xmax in a six-value bbox. A file written by GDAL from geometries with Z was pruned by a filter that matches its rows, and the query returned too few rows. The filter now takes X and Y from a bbox of four, six or eight values and keeps a file whose bbox has another number of values.
RFC 7946 lists the west bound of such a bbox first, so its xmin is greater than its xmax. The spatial filter built an envelope from the two values, which sorts them, and pruned a file with matching rows. That already happened for a bbox with four values; reading the right positions of a bbox with six values brought it to those files too. The filter now keeps a file whose bounds are not in order, NaN included. The bboxes in the tests have different upper bounds for X and Y, and one window is inside by Y only, so that the tests tell the two apart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes GeoParquet spatial filter drops matching rows when the bbox of a column has Z bounds #3560.What changes were proposed in this PR?
The
bboxof a geometry column in GeoParquet metadata lists the minimum of every dimension and then the maximum of every dimension: four values for XY, six for XYZ, and in GeoParquet 2.0 eight for XYZM. The spatial filter of thegeoparquetreader read positions 0 to 3 as xmin, ymin, xmax and ymax whatever the length, so for a six-valuebboxit took zmin for xmax. A pushed-down filter then pruned a file that holds matching rows, and the query returned too few rows.Sedona's writer stores four values, so this shows with files from other writers. GDAL 3.13.1 stores six values for geometries with Z.
GeoParquetSpatialFilter.LeafFilternow takes X and Y from abboxof four, six or eight values. A file whosebboxhas another number of values is kept, where the filter used to fail with anIndexOutOfBoundsExceptionfor fewer than four values.The filter also keeps a file whose
bboxcrosses the antimeridian. RFC 7946, which the GeoParquet specification follows forbbox, lists the west bound first for such a box, so xmin is greater than xmax, for example[170, -5, -170, 5]. The filter used to build an envelope from the two values, which sorts them into -170 to 170 and leaves out a point at 179°E. That happened for a four-valuebboxbefore this PR; reading the right positions of a six-valuebboxwould have brought it to those files as well. Abboxwhose bounds are not in order for another reason, NaN included, keeps the file too.Not in this PR: the writer still stores four values for a column with Z.
How was this patch tested?
GeoParquetSpatialFilterPushDownSuitehas new tests:bboxwith four, six and eight values. The boxes have different upper bounds for X and Y, and one window is inside by Y only, so a mix-up of the two is caught.bboxthat crosses the antimeridian keeps the file, with four, six and eight values.bboxwith bounds that are not in order, or with another number of values, keeps the file.geoparquet/gdal/point-z.parquetin the test resources, 3 KB.The tests for Z bounds, the antimeridian and unordered bounds fail without the change.
The GeoParquet suites pass locally on Spark 4.2 / Scala 2.13 and Spark 4.1 / Scala 2.13. On Spark 3.5 / Scala 2.12 I ran
GeoParquetSpatialFilterPushDownSuite,GeoParquetMetadataTestsandgeoparquetIOTests.Did this PR include necessary documentation updates?