Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Enable to_json_string for physical plan #3023

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colin-ho
Copy link
Contributor

@colin-ho colin-ho commented Oct 8, 2024

#2977

Allows physical plan to be serialized to be json strings. The script below shows how you can extract the sql queries from read sql.

import daft
import json

def create_conn():
    return create_engine('sqlite:///test_database.db').connect()

df = daft.read_sql("SELECT * FROM test_data", create_conn, partition_col="id", num_partitions=3)
physical_plan_scheduler = df._builder.to_physical_plan_scheduler(
    daft.context.get_context().daft_execution_config
)

physical_plan_dict = json.loads(physical_plan_scheduler.to_json_string())

# collect all sql queries
sql_queries = []
for task in physical_plan_dict['TabularScan']['scan_tasks']:
    sql_queries.append(task['file_format_config']['Database']['sql'])
print(sql_queries)

['SELECT * FROM (SELECT * FROM test_data) AS subquery WHERE id >= 1 AND id < 34', 'SELECT * FROM (SELECT * FROM test_data) AS subquery WHERE id >= 34 AND id < 67', 'SELECT * FROM (SELECT * FROM test_data) AS subquery WHERE id >= 67 AND id <= 100']

Copy link

codspeed-hq bot commented Oct 8, 2024

CodSpeed Performance Report

Merging #3023 will not alter performance

Comparing colin/physical-plan-json (322a3a0) with main (64b8699)

Summary

✅ 17 untouched benchmarks

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.48%. Comparing base (3f37a69) to head (322a3a0).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/daft-scheduler/src/scheduler.rs 0.00% 4 Missing ⚠️
daft/plan_scheduler/physical_plan_scheduler.py 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3023      +/-   ##
==========================================
+ Coverage   78.43%   78.48%   +0.05%     
==========================================
  Files         603      609       +6     
  Lines       71504    71705     +201     
==========================================
+ Hits        56086    56281     +195     
- Misses      15418    15424       +6     
Files with missing lines Coverage Δ
daft/plan_scheduler/physical_plan_scheduler.py 54.90% <50.00%> (-0.21%) ⬇️
src/daft-scheduler/src/scheduler.rs 92.85% <0.00%> (-0.61%) ⬇️

... and 38 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant