[GH-3126] Fix STAC temporal pushdown and pagination - #3130
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the correctness and safety of STAC pushdown and planning in Sedona’s Spark STAC datasource by refining temporal envelope computation, limiting behavior, and pagination/link handling to avoid false negatives and inconsistent page scheduling.
Changes:
- Reworked temporal pushdown to compute conservative envelopes (AND = intersection, OR = convex hull), preserve open endpoints, and omit unbounded/unsafe temporal pushdown.
- Tightened limit pushdown to only apply when a limit is directly above the target STAC scan, and safely combines SQL limit with configured caps.
- Fixed pagination/link planning to reuse the filtered first-page URL consistently, resolve relative links against the containing document, and preserve server-provided
nextlinks.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/optimization/SpatialTemporalFilterPushDownForStacScan.scala | Restricts temporal pushdown to STAC datetime and applies only direct limits to scans. |
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/io/stac/StacUtils.scala | Introduces conservative temporal bound calculation and safer datetime serialization. |
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/io/stac/StacBatch.scala | Fixes first-page planning/pagination link resolution and improves temporal extent pruning and limit handling. |
| spark/common/src/test/scala/org/apache/spark/sql/sedona_sql/optimization/SpatialTemporalFilterPushDownForStacScanTest.scala | Adds coverage for unbounded-OR omission, non-datetime timestamps, and direct-limit extraction. |
| spark/common/src/test/scala/org/apache/spark/sql/sedona_sql/io/stac/StacUtilsTest.scala | Updates/adds tests for OR/AND temporal bound behavior, including omission of unsafe intervals. |
| spark/common/src/test/scala/org/apache/spark/sql/sedona_sql/io/stac/StacBatchTest.scala | Adds HTTP-server-backed pagination tests, query/fragment preservation, limit combination, and temporal pruning cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
172
to
174
| // Extract item links from the "links" array | ||
| val linksNode = rootNode.get("links") | ||
| val iterator = linksNode.elements() |
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]format. Closes [BUG] STAC temporal OR pushdown can narrow unbounded predicates #3126.What changes were proposed in this PR?
ANDpredicates and taking the convex hull ofORpredicates, while preserving unbounded endpoints and omitting unsafe or empty remote intervals.datetimecolumn to the remote temporal parameter.nextlinks unchanged.The temporal false negatives came from using the same widening logic for
ANDandOR, which could erase an unbounded side of anORpredicate. The pagination path also scheduled a different first URL than it inspected and treated relative pagination links as catalog-root paths. Together, those behaviors could omit matching items or read the wrong pages before Spark applied its residual operators.How was this patch tested?
mvn -pl spark/common -Dspark=3.4 -Dscala=2.12 -Dgeotools -DwildcardSuites=org.apache.spark.sql.sedona_sql.io.stac.StacBatchTest,org.apache.spark.sql.sedona_sql.io.stac.StacUtilsTest,org.apache.spark.sql.sedona_sql.optimization.SpatialTemporalFilterPushDownForStacScanTest clean testmvn -pl spark/common -Dspark=3.4 -Dscala=2.13 -Dgeotools -DwildcardSuites=org.apache.spark.sql.sedona_sql.io.stac.StacBatchTest,org.apache.spark.sql.sedona_sql.io.stac.StacUtilsTest,org.apache.spark.sql.sedona_sql.optimization.SpatialTemporalFilterPushDownForStacScanTest clean testBoth variants passed 240 Java tests and 59 targeted Scala tests.
Did this PR include necessary documentation updates?