Skip to content

fix: handle EXISTS/NOT EXISTS subqueries in federation analyzer#68

Merged
sgrebnov merged 2 commits into
spiceai-52from
sgrebnov/0404-fix-exists
Apr 19, 2026
Merged

fix: handle EXISTS/NOT EXISTS subqueries in federation analyzer#68
sgrebnov merged 2 commits into
spiceai-52from
sgrebnov/0404-fix-exists

Conversation

@sgrebnov
Copy link
Copy Markdown

@sgrebnov sgrebnov commented Apr 4, 2026

🗣 Description

Cross-provider queries with EXISTS/NOT EXISTS subquery filters fail because the federation analyzer doesn't inspect tables inside Expr::Exists. As a result the analyzer only sees the outer query's tables, concludes single provider, and federates the entire query — including the subquery's tables — to one DBMS, where the subquery's table doesn't exist (e.g., no such table: lineitem)

🔨 Related Issues

Fixes spiceai/spiceai#10167

🤔 Concerns

@sgrebnov sgrebnov marked this pull request as ready for review April 5, 2026 09:10
Copilot AI review requested due to automatic review settings April 5, 2026 09:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes federation analysis for cross-provider queries that use EXISTS/NOT EXISTS predicate subqueries by ensuring the analyzer inspects tables referenced inside Expr::Exists and federates subqueries correctly.

Changes:

  • Extend provider scanning to traverse Expr::Exists subquery plans when determining whether a subtree is single-provider or cross-provider.
  • Extend expression rewriting to recursively analyze/federate EXISTS subqueries, including a compatibility workaround for optimizer rules by wrapping federated subqueries in a no-op Projection when needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sgrebnov sgrebnov self-assigned this Apr 5, 2026
Comment thread datafusion-federation/src/analyzer/mod.rs
@sgrebnov sgrebnov merged commit d691dba into spiceai-52 Apr 19, 2026
11 checks passed
@sgrebnov sgrebnov deleted the sgrebnov/0404-fix-exists branch April 19, 2026 12:52
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.

3 participants