Skip to content

Commit dc7cb2a

Browse files
authored
chore(tool): add manifest extract for query_local_run (#1191)
1 parent 9465ec8 commit dc7cb2a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ibis-server/tools/query_local_run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from wren_core import SessionContext
2323
from app.model.data_source import BigQueryConnectionInfo
2424
from app.model.data_source import DataSourceExtension
25+
import wren_core
2526

2627
if sys.stdin.isatty():
2728
print("please provide the SQL query via stdin, e.g. `python query_local_run.py < test.sql`", file=sys.stderr)
@@ -57,6 +58,14 @@
5758
with open(connection_info_path) as file:
5859
connection_info = json.load(file)
5960

61+
# Extract the requried tables from the SQL query
62+
extractor = wren_core.ManifestExtractor(encoded_str)
63+
tables = extractor.resolve_used_table_names(sql)
64+
print("# Tables used in the SQL query:", tables)
65+
# Extract the manifest for the required tables
66+
manifest = extractor.extract_by(tables)
67+
encoded_str = wren_core.to_json_base64(manifest)
68+
6069
print("### Starting the session context ###")
6170
print("#")
6271
session_context = SessionContext(encoded_str, function_list_path + f"/{data_source}.csv")

0 commit comments

Comments
 (0)