Skip to content

[GH-3126] Fix STAC temporal pushdown and pagination - #3130

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix/stac-temporal-or-pushdown
Jul 20, 2026
Merged

[GH-3126] Fix STAC temporal pushdown and pagination#3130
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix/stac-temporal-or-pushdown

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

  • Compute conservative temporal envelopes by intersecting AND predicates and taking the convex hull of OR predicates, while preserving unbounded endpoints and omitting unsafe or empty remote intervals.
  • Prune collection extents by interval overlap at nanosecond precision and only translate the STAC datetime column to the remote temporal parameter.
  • Restrict SQL limit pushdown to a limit directly above the target scan and combine it safely with the configured item cap.
  • Make STAC pagination use the same filtered first-page URL for planning and reading, resolve relative links against the document that contains them, count actual returned features, and preserve server-provided next links unchanged.

The temporal false negatives came from using the same widening logic for AND and OR, which could erase an unbounded side of an OR predicate. 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 test
  • mvn -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 test

Both variants passed 240 Java tests and 59 targeted Scala tests.

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API, so no documentation update is needed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 next links.

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()
@jiayuasu
jiayuasu marked this pull request as ready for review July 20, 2026 05:19
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 20, 2026
@jiayuasu
jiayuasu merged commit 8656264 into apache:master Jul 20, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] STAC temporal OR pushdown can narrow unbounded predicates

2 participants