summaryrefslogtreecommitdiffstats
path: root/tests/tpch.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-03 07:31:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-03 07:31:54 +0000
commitb38d717d5933fdae3fe85c87df7aee9a251fb58e (patch)
tree6db21a44ffea4c832dcab29688bfaf1c1dc124f9 /tests/tpch.py
parentReleasing debian version 11.4.1-1. (diff)
downloadsqlglot-b38d717d5933fdae3fe85c87df7aee9a251fb58e.tar.xz
sqlglot-b38d717d5933fdae3fe85c87df7aee9a251fb58e.zip
Merging upstream version 11.4.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/tpch.py')
-rw-r--r--tests/tpch.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/tpch.py b/tests/tpch.py
new file mode 100644
index 0000000..0b6de63
--- /dev/null
+++ b/tests/tpch.py
@@ -0,0 +1,37 @@
+import time
+
+from sqlglot.optimizer import optimize
+
+INPUT = ""
+OUTPUT = ""
+NUM = 99
+SCHEMA = {}
+KIND = "DS"
+
+with open(OUTPUT, "w", encoding="UTF-8") as fixture:
+ for i in range(NUM):
+ i = i + 1
+ with open(INPUT.format(i=i), encoding="UTF-8") as file:
+ original = "\n".join(
+ line.rstrip()
+ for line in file.read().split(";")[0].split("\n")
+ if not line.startswith("--")
+ )
+ original = original.replace("`", '"')
+ now = time.time()
+ try:
+ optimized = optimize(original, schema=SCHEMA)
+ except Exception as e:
+ print("****", i, e, "****")
+ continue
+
+ fixture.write(
+ f"""--------------------------------------
+-- TPC-{KIND} {i}
+--------------------------------------
+{original};
+{optimized.sql(pretty=True)};
+
+"""
+ )
+ print(i, time.time() - now)