Skip to content

Make the batch benchmark queries portable across all three engines - #60

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/batch-queries-portable-dialect
Jul 22, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/batch-queries-portable-dialect

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The batch queries.sql is the single source run by all three benchmark runners (PostgreSQL, DuckDB, Spark). Seven queries used PostgreSQL-only syntax that Spark and DuckDB cannot parse, so the "runs unchanged on all three engines" contract did not actually hold for them:

  • the && bounding-box overlap operator in q09 and q11–q16
  • a ::numeric cast in q09

Each && spatial prefilter is replaced with the th3index cell prefilter already used by q02 and q04:

  • eEq(geoToH3IndexSet(geom, 7), trip_h3) for polygon inputs (q13, q14, q16)
  • COALESCE(eEq(geoToH3Cell(geom, 7), trip_h3), TRUE) for point inputs (q11, q12, q15)

Both are sound conservative prefilters that every engine supports, and the exact predicate that follows each is unchanged — so the results are identical, only the prefilter expression differs. For q09 the temporal && becomes the equivalent atTime(...) IS NOT NULL guard and the PostgreSQL-only ::numeric round is dropped, matching the portable form.

All 18 @query markers are preserved; only the seven prefilter expressions change.

queries.sql is the single source run by every batch runner (PostgreSQL,
DuckDB, Spark), but seven queries used PostgreSQL-only syntax that Spark
and DuckDB cannot parse: the && bounding-box overlap operator (q09,
q11-q16) and a ::numeric cast in q09.

Replace each && spatial prefilter with the th3index cell prefilter
already used by q02 and q04 -- eEq(geoToH3IndexSet(geom, 7), trip_h3)
for polygon inputs, COALESCE(eEq(geoToH3Cell(geom, 7), trip_h3), TRUE)
for point inputs. Both are sound conservative prefilters supported by
every engine, and the exact predicate that follows each is unchanged,
so the results are identical. For q09's temporal prefilter, use the
equivalent atTime(...) IS NOT NULL guard and drop the PostgreSQL-only
::numeric round, matching the portable form.

All 18 @query markers are preserved; only the seven prefilter
expressions change.
@estebanzimanyi
estebanzimanyi merged commit db49ac4 into MobilityDB:master Jul 22, 2026
2 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.

1 participant