Skip to content

feat(sql): add direct SQL query support#144

Closed
jja725 wants to merge 2 commits intolance-format:mainfrom
jja725:feat/sql-query-support
Closed

feat(sql): add direct SQL query support#144
jja725 wants to merge 2 commits intolance-format:mainfrom
jja725:feat/sql-query-support

Conversation

@jja725
Copy link
Contributor

@jja725 jja725 commented Feb 26, 2026

Summary

  • Add SqlQuery and SqlEngine (Rust + Python) for running standard SQL directly against datasets via DataFusion, without requiring a GraphConfig
  • Useful for data analytics workflows with explicit JOINs, aggregations, and filtering against node/relationship tables
  • Mirror the existing CypherQuery/CypherEngine patterns

Test plan

  • cargo test --package lance-graph — 14 Rust integration tests + 9 unit tests + doctest pass
  • pytest python/tests/test_sql.py — 18 Python tests pass (SqlQuery: 14, SqlEngine: 4)
  • Covers: SELECT/WHERE/ORDER BY/LIMIT, JOINs, aggregations (COUNT/SUM/AVG), GROUP BY, explain, error handling, case-insensitive table names, SessionContext execution

@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 86.95652% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/lance-graph/src/sql_query.rs 86.84% 30 Missing ⚠️

📢 Thoughts on this report? Let us know!

Add SqlQuery and SqlEngine that let users run standard SQL directly
against their datasets without requiring a GraphConfig. This is useful
for data analytics workflows where users want explicit JOINs and
aggregations against node/relationship tables. DataFusion handles SQL
parsing and execution.
@jja725 jja725 force-pushed the feat/sql-query-support branch from cc9bea2 to caa792d Compare February 26, 2026 07:28
@ChunxuTang
Copy link
Collaborator

@jja725 Thanks for the contribution! Could you explain the differences between this new interface and the existing to_sql API? Meanwhile, could you also update the Python docs accordingly?

@jja725
Copy link
Contributor Author

jja725 commented Feb 26, 2026

Hi @ChunxuTang, my understanding is that
to_sql() is a debugging/inspection tool that shows the SQL a Cypher query compiles to. SqlQuery/SqlEngine are execution interfaces for users who want to write SQL directly for data analytics without the Cypher layer.

@beinan
Copy link
Collaborator

beinan commented Mar 3, 2026

do we still need this pr? looks like the sql interface implemented in another pr

@jja725 jja725 closed this Mar 3, 2026
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.

4 participants