-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Enable to_json_string for physical plan (#3023)
#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'] ``` --------- Co-authored-by: Colin Ho <[email protected]>
- Loading branch information
Showing
6 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters