Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoying committed Jun 23, 2023
1 parent 6abbbc2 commit f3b05d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions benchmarks/tpch-fed.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
Usage:
tpch-fed.py [--file=<file>] [--dir=<dir>] [--runs=<runs>]
tpch-fed.py [--file=<file>] [--dir=<dir>] [--runs=<runs>] [--print]
Options:
--file=<file> Query file.
--dir=<dir> Query path.
--runs=<runs> # runs [default: 1].
--print Print query result.
-h --help Show this screen.
--version Show version.
"""
Expand All @@ -18,7 +19,7 @@
from docopt import docopt
from pathlib import Path

def run_query_from_file(query_file, ntries=0):
def run_query_from_file(query_file, doprint=False, ntries=0):
with open(query_file, "r") as f:
sql = f.read()
print(f"file: {query_file}")
Expand All @@ -27,6 +28,8 @@ def run_query_from_file(query_file, ntries=0):
with Timer() as timer:
df = cx.read_sql(db_map, sql, return_type="arrow")
print(f"time in total: {timer.elapsed:.2f}, {len(df)} rows, {len(df.columns)} cols")
if doprint:
print(df)
del df
# print(df.schema)
# print(df)
Expand Down Expand Up @@ -58,9 +61,9 @@ def run_query_from_file(query_file, ntries=0):
sys.stdout.flush()
if args["--file"]:
filename = args["--file"]
run_query_from_file(filename)
run_query_from_file(filename, args["--print"])
elif args["--dir"]:
for filename in sorted(Path(args["--dir"]).glob("q*.sql")):
run_query_from_file(filename)
run_query_from_file(filename, args["--print"])
time.sleep(2)

0 comments on commit f3b05d3

Please sign in to comment.