Skip to content

Conversation

@ChunxuTang
Copy link
Collaborator

This PR

  • adds an explain_datafusion method to show the generated plans (graph logical plan, DataFusion logical plan, DataFusion physical plan) in the DataFusion-based query execution pipeline. It is similar to the EXPLAIN method in DataFusion.
  • adds a test file with examples to show the output. To explicitly see the plan results, run cargo test --test test_explain_output -- --nocapture --test-threads=1

Example query and output:

MATCH (p:Person) RETURN p.name, p.age
+--------------------+----------------------------------------------------------------------------------------------------------------------+
| plan_type          | plan                                                                                                                 |
+--------------------+----------------------------------------------------------------------------------------------------------------------+
| graph_logical_plan | Project {                                                                                                            |
|                    |     input: ScanByLabel {                                                                                             |
|                    |         variable: "p",                                                                                               |
|                    |         label: "Person",                                                                                             |
|                    |         properties: {},                                                                                              |
|                    |     },                                                                                                               |
|                    |     projections: [                                                                                                   |
|                    |         ProjectionItem {                                                                                             |
|                    |             expression: Property(                                                                                    |
|                    |                 PropertyRef {                                                                                        |
|                    |                     variable: "p",                                                                                   |
|                    |                     property: "name",                                                                                |
|                    |                 },                                                                                                   |
|                    |             ),                                                                                                       |
|                    |             alias: None,                                                                                             |
|                    |         },                                                                                                           |
|                    |         ProjectionItem {                                                                                             |
|                    |             expression: Property(                                                                                    |
|                    |                 PropertyRef {                                                                                        |
|                    |                     variable: "p",                                                                                   |
|                    |                     property: "age",                                                                                 |
|                    |                 },                                                                                                   |
|                    |             ),                                                                                                       |
|                    |             alias: None,                                                                                             |
|                    |         },                                                                                                           |
|                    |     ],                                                                                                               |
|                    | }                                                                                                                    |
| logical_plan       | Projection: p__name AS p.name, p__age AS p.age                                                                       |
|                    |   Projection: person.person_id AS p__person_id, person.name AS p__name, person.age AS p__age, person.city AS p__city |
|                    |     TableScan: person                                                                                                |
| physical_plan      | ProjectionExec: expr=[name@0 as p.name, age@1 as p.age]                                                              |
|                    |   DataSourceExec: partitions=1, partition_sizes=[1]                                                                  |
+--------------------+----------------------------------------------------------------------------------------------------------------------+

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 87.07865% with 23 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@60e7756). Learn more about missing BASE report.

Files with missing lines Patch % Lines
rust/lance-graph/src/query.rs 87.07% 23 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #29   +/-   ##
=======================================
  Coverage        ?   80.07%           
=======================================
  Files           ?       16           
  Lines           ?     7191           
  Branches        ?        0           
=======================================
  Hits            ?     5758           
  Misses          ?     1433           
  Partials        ?        0           
Flag Coverage Δ
rust-unittests 80.07% <87.07%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@beinan beinan merged commit 26dfb0e into lance-format:main Nov 2, 2025
9 checks passed
@ChunxuTang ChunxuTang deleted the explain branch November 16, 2025 04:14
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