feat(rust/sedona): Spark's array(...) spelling via datafusion-spark; RS_Values parity catalog - #1293
Open
james-willis wants to merge 2 commits into
Open
feat(rust/sedona): Spark's array(...) spelling via datafusion-spark; RS_Values parity catalog#1293james-willis wants to merge 2 commits into
james-willis wants to merge 2 commits into
Conversation
…on-spark DataFusion's core renamed array() to make_array() in apache/datafusion#3122 (sqlparser had reserved the ARRAY keyword); the parser restriction is long gone and the Spark spelling now ships upstream in the datafusion-spark compatibility crate (apache/datafusion#16932). Registering that UDF in SedonaContext::finish_new lets Spark SQL that builds arrays run unchanged on every SedonaDB surface; [...] literals and make_array() are unaffected.
Contributor
Author
|
@paleolimbot not sure if we have any reservations about using the spark comp crate |
james-willis
marked this pull request as ready for review
September 11, 2026 20:08
paleolimbot
reviewed
Sep 12, 2026
paleolimbot
left a comment
Member
There was a problem hiding this comment.
Getting Spark parity on SQL is I think a great idea, just one that requires a standalone project. Something like "set SQL dialect to Spark", where we've spent some time to make sure all the other functions line up, too.
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.
Registers Spark's
array(...)constructor spelling in SedonaDB, taken from DataFusion's own Spark-compatibility crate, and uses it to open the RS_Values parity catalog — the last RS_ function with no coverage besides RS_AsGeoTiff.Why the spelling was missing, and why it's safe to add back
DataFusion's core renamed
array()tomake_array()in 2022 (apache/datafusion#3122): sqlparser-rs#566 had reserved theARRAYkeyword for Postgres-styleARRAY[...]literals, which "makes it impossible to usearrayas a function" — and Postgres itself rejectsarray(1, 2). That parser restriction is long gone (probing showedarray(1, 2)reaches DataFusion's planner today, failing only on resolution), and upstream now ships Spark'sarrayas a UDF in the datafusion-spark compatibility crate (apache/datafusion#16932), sqllogictests included, reusing make_array's kernel and coercion.So rather than hand-rolling an alias, this adds
datafusion-spark(54.1.0, matching the workspace) as a dependency and registers itsarrayUDF inSedonaContext::finish_new, where both constructors funnel — every surface gets it.[...]literals andmake_array()are untouched.Probed semantics (both engines)
array(1, 2, 3),ARRAY(1, 2, 3)[1, 2, 3][1, 2, 3]array(NULL, 1)[None, 1][None, 1]array(array(1), array(2))[[1], [2]][[1], [2]]array(1, 'x')array(1, 2.5)[1.0, 2.5](float64)2.5literal as DECIMAL; not an array() divergencearray()[]Tests: a Rust test in
context.rsand a Python test intest_context.py, both assertingarray(1, 2) = [1, 2] = make_array(1, 2).RS_Values catalog (second commit)
With one shared spelling available,
test_rs_values.pycan finally exist. It is a pure divergence catalog — today every spelling of RS_Values is accepted by exactly one engine:RS_Values(rast, array(ST_GeomFromWKT(...), ...)[, band])): SedonaDB has no list-of-geometries kernel; Sedona Spark answers[255.0, 112.0].[255.0, 112.0](one value per part); Sedona Spark rejects a non-array geometry argument outright.RS_Values(rast, array(1, 2), array(1, 1), 1)): SedonaDB has no kernel; Sedona Spark answers[193.0, 255.0]— and those values pin its coordinate basis as 0-based, unlike its own 1-based RS_PixelAs* functions.All anchor values are hand-derivable from the standard seeded grid (stated in the module docstring).
Full spark-parity suite on this branch:
176 passed, 103 xfailedlocally (main plus the four new xfails). Independent of #1286.