Skip to content

feat(federation): let a SqlTable's federated scan take a sort - #91

Merged
krinart merged 2 commits into
spiceai-55from
viktor/sqltable-sort-pushdown
Oct 13, 2026
Merged

krinart merged 2 commits into
spiceai-55from
viktor/sqltable-sort-pushdown

Conversation

@krinart

@krinart krinart commented Oct 12, 2026 •

Copy link
Copy Markdown

SqlTable opts in to the federated sort pushdown that spiceai/datafusion-federation#93 adds. SQLExecutor::supports_sort_pushdown returns allow_physical_sort_pushdown, the switch SqlExec::try_pushdown_sort already honors. A sort above a federated SqlTable scan then reaches the remote engine instead of being applied locally to every row. A table with the switch off, as ScyllaDB sets it, keeps the sort local, as its own scan already does.

The datafusion-federation pin moves to 0ef7d34, the spiceai-55 squash merge of spiceai/datafusion-federation#93, which adds the trait method. dtp's other table types (MySQLTable, DuckDBTable, SQLiteTable, AdbcDBTable, ClickHouseTable) keep the default, false, so their behavior is unchanged.

Spice moves both pins together in spiceai/spiceai#15078, because it takes datafusion-federation from the same git URL.

Evidence (commit 44f0766, 2026-10-12; ad4e086 only repoints the pin from e93dfc3 to 0ef7d34, whose trees are identical)

cargo test -p datafusion-table-providers --lib --features federation sql_provider_datafusion
# test result: ok. 128 passed; 0 failed   (incl. the new federated_sort_pushdown_follows_the_scans_switch)
cargo clippy -p datafusion-table-providers --features sqlite-federation -- -D warnings   # exit 0
cargo fmt --all -- --check                                                               # clean
cargo metadata --format-version 1                                                        # Cargo.lock: the one federation source line

Spice-side, with this commit and spiceai/datafusion-federation#93 patched in by path: crates/data_components/src/federation.rs::tests::sort_pushdown::a_sort_above_a_refused_projection_reaches_the_source fails with the opt-in removed and fails with the switch ignored. It passes with this change. Its PostgreSQL end-to-end numbers are in spiceai/datafusion-federation#93.

`SqlTable::supports_sort_pushdown` returns `allow_physical_sort_pushdown`,
the switch its own scan already honors, so a sort above a federated
`SqlTable` scan reaches the remote engine instead of sorting every row
locally. A table with the switch off (ScyllaDB) keeps the sort local.

Pins datafusion-federation at spiceai/datafusion-federation#93, which adds
`SQLExecutor::supports_sort_pushdown`.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 23:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The existing switch does not guarantee the exact collation semantics required by federated sort pushdown.

1 open finding
What changed in this PR

Enables federated SqlTable scans to push sorts into remote SQL.

Changes:

  • Connects federated sort support to the existing physical-sort switch.
  • Adds switch-behavior coverage.
  • Updates the federation dependency pin.
File Description
core/​src/​sql/​sql_provider_datafusion/​federation.rs Enables and tests federated sort pushdown.
Cargo.toml Updates the federation revision.
Cargo.lock Locks the updated revision.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

spiceai/datafusion-federation#93 was squash-merged as 0ef7d34, whose tree
is identical to e93dfc3, the head this branch pinned.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 23:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approved

The implementation consistently honors the existing opt-out switch, includes focused coverage, and uses a valid dependency revision.

1 open finding

🧠 Review effort: Balanced

@krinart krinart self-assigned this Oct 12, 2026
@krinart
krinart merged commit 201f519 into spiceai-55 Oct 13, 2026
14 of 15 checks passed
@krinart
krinart deleted the viktor/sqltable-sort-pushdown branch October 13, 2026 00:51
krinart added a commit to spiceai/spiceai that referenced this pull request Oct 13, 2026
spiceai/datafusion-table-providers#91 was squash-merged as 201f519, whose
tree is identical to ad4e086, the branch head pinned before. Both forks are
now on landed revisions, so the TEMPORARY marker is dropped.
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.

2 participants