PostBOUND 0.22.2__tar.gz → 0.23.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {postbound-0.22.2 → postbound-0.23.0}/PKG-INFO +6 -20
- {postbound-0.22.2 → postbound-0.23.0}/PostBOUND.egg-info/PKG-INFO +6 -20
- {postbound-0.22.2 → postbound-0.23.0}/PostBOUND.egg-info/SOURCES.txt +0 -1
- {postbound-0.22.2 → postbound-0.23.0}/PostBOUND.egg-info/requires.txt +0 -3
- {postbound-0.22.2 → postbound-0.23.0}/README.md +5 -17
- {postbound-0.22.2 → postbound-0.23.0}/postbound/__init__.pyi +0 -2
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_core.py +28 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_ipython.py +15 -6
- {postbound-0.22.2 → postbound-0.23.0}/postbound/db/__init__.py +6 -1
- {postbound-0.22.2 → postbound-0.23.0}/postbound/db/_db.py +785 -361
- {postbound-0.22.2 → postbound-0.23.0}/postbound/db/_stats.py +3 -11
- {postbound-0.22.2 → postbound-0.23.0}/postbound/duckdb/_duckdb.py +72 -127
- {postbound-0.22.2 → postbound-0.23.0}/postbound/postgres/_explain.py +6 -6
- {postbound-0.22.2 → postbound-0.23.0}/postbound/postgres/_pg.py +210 -313
- {postbound-0.22.2 → postbound-0.23.0}/postbound/qal/__init__.py +2 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/qal/_qal.py +49 -5
- {postbound-0.22.2 → postbound-0.23.0}/pyproject.toml +48 -59
- postbound-0.23.0/tests/test_duckdb.py +332 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_postgres.py +38 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_qal.py +1 -1
- postbound-0.22.2/postbound/mysql.py +0 -1164
- postbound-0.22.2/tests/test_duckdb.py +0 -156
- {postbound-0.22.2 → postbound-0.23.0}/LICENSE.txt +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/PostBOUND.egg-info/dependency_links.txt +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/PostBOUND.egg-info/top_level.txt +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_base.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_hints.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_pipelines.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_qep.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/_stages.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/bench.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/db/_cache.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/duckdb/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/__init__.pyi +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_cardinalities.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_dynprog.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_enumeration.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_helpers.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_native.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/opt/_randomized.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/parser.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/postgres/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/postgres/_config.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/postgres/_ctl.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/qal/_formatter.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/relalg.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/train/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/train/_train.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/transform.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/__init__.pyi +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/_df.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/_errors.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/collections.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/dicts.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/jsonize.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/logging.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/misc.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/num.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/nx.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/proc.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/stats.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/system.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/util/typing.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/validation.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/__init__.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/__init__.pyi +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/fdl.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/graphs.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/optimizer.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/plots.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/vis/trees.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/postbound/workloads.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/setup.cfg +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_benchmarking.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_core.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_docs.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_relalg.py +0 -0
- {postbound-0.22.2 → postbound-0.23.0}/tests/test_util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PostBOUND
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: PostBOUND is a research framework to prototype and benchmark database query optimizers
|
|
5
5
|
Author-email: Rico Bergmann <rico.bergmann1@tu-dresden.de>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -27,8 +27,6 @@ Provides-Extra: vis
|
|
|
27
27
|
Requires-Dist: matplotlib~=3.10; extra == "vis"
|
|
28
28
|
Requires-Dist: seaborn~=0.13; extra == "vis"
|
|
29
29
|
Requires-Dist: graphviz~=0.21; extra == "vis"
|
|
30
|
-
Provides-Extra: mysql
|
|
31
|
-
Requires-Dist: mysql-connector-python~=9.5; extra == "mysql"
|
|
32
30
|
Dynamic: license-file
|
|
33
31
|
|
|
34
32
|
# PostBOUND
|
|
@@ -111,7 +109,7 @@ For DuckDB, PostBOUND uses [quacklab](https://github.com/rbergm/quacklab) hints
|
|
|
111
109
|
|
|
112
110
|
> [!NOTE]
|
|
113
111
|
> PostBOUND's database interaction is designed to be independent of a specific system (such as PostgreSQL, Oracle, ...).
|
|
114
|
-
>
|
|
112
|
+
> Currently, we focus on the Postgres (most complete) and DuckDB backends.
|
|
115
113
|
> This is due to practical reasons, mostly our own time budget and the popularity of the two systems in the optimizer research
|
|
116
114
|
> community.
|
|
117
115
|
|
|
@@ -146,16 +144,11 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
146
144
|
if not pb.qal.is_select_query(query):
|
|
147
145
|
raise pb.OptimizationError("Expected a SELECT query")
|
|
148
146
|
|
|
149
|
-
initial_table, *free_tables = random.sample(
|
|
150
|
-
list(query.tables()), k=len(query.tables())
|
|
151
|
-
)
|
|
147
|
+
initial_table, *free_tables = random.sample(list(query.tables()), k=len(query.tables()))
|
|
152
148
|
join_tree = pb.JoinTree(base_table=initial_table)
|
|
153
149
|
|
|
154
150
|
while free_tables:
|
|
155
|
-
candidates = [
|
|
156
|
-
table for table in free_tables
|
|
157
|
-
if query.joins_between(table, join_tree.tables())
|
|
158
|
-
]
|
|
151
|
+
candidates = [table for table in free_tables if query.joins_between(table, join_tree.tables())]
|
|
159
152
|
next_table = random.choice(candidates)
|
|
160
153
|
join_tree = join_tree.join_with(next_table)
|
|
161
154
|
free_tables.remove(next_table)
|
|
@@ -169,11 +162,7 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
169
162
|
pg_stats = pb.postgres.connect(config_file=".psycopg_connection_stats")
|
|
170
163
|
stats = pb.workloads.stats()
|
|
171
164
|
|
|
172
|
-
optimization_pipeline = (
|
|
173
|
-
pb.MultiStageOptimizationPipeline(pg_stats)
|
|
174
|
-
.use(RandomJoinOrder())
|
|
175
|
-
.build()
|
|
176
|
-
)
|
|
165
|
+
optimization_pipeline = pb.MultiStageOptimizationPipeline(pg_stats).use(RandomJoinOrder()).build()
|
|
177
166
|
|
|
178
167
|
# (Step 3): in this example we just compare against the native Postgres optimizer
|
|
179
168
|
# Therefore, we do not need to setup any additional optimizers.
|
|
@@ -181,9 +170,7 @@ optimization_pipeline = (
|
|
|
181
170
|
# Step 4: execute the workload.
|
|
182
171
|
# We use the QueryPreparation to prewarm the database buffer and run all
|
|
183
172
|
# queries as EXPLAIN ANALYZE.
|
|
184
|
-
query_prep = pb.bench.QueryPreparation(
|
|
185
|
-
prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"]
|
|
186
|
-
)
|
|
173
|
+
query_prep = pb.bench.QueryPreparation(prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"])
|
|
187
174
|
native_results = pb.bench.execute_workload(
|
|
188
175
|
stats,
|
|
189
176
|
on=pg_stats,
|
|
@@ -200,7 +187,6 @@ optimized_results = pb.bench.execute_workload(
|
|
|
200
187
|
progressive_output="stats-results-optimized.csv",
|
|
201
188
|
logger="tqdm",
|
|
202
189
|
)
|
|
203
|
-
|
|
204
190
|
```
|
|
205
191
|
|
|
206
192
|
## 🤬 Issues
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PostBOUND
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.0
|
|
4
4
|
Summary: PostBOUND is a research framework to prototype and benchmark database query optimizers
|
|
5
5
|
Author-email: Rico Bergmann <rico.bergmann1@tu-dresden.de>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -27,8 +27,6 @@ Provides-Extra: vis
|
|
|
27
27
|
Requires-Dist: matplotlib~=3.10; extra == "vis"
|
|
28
28
|
Requires-Dist: seaborn~=0.13; extra == "vis"
|
|
29
29
|
Requires-Dist: graphviz~=0.21; extra == "vis"
|
|
30
|
-
Provides-Extra: mysql
|
|
31
|
-
Requires-Dist: mysql-connector-python~=9.5; extra == "mysql"
|
|
32
30
|
Dynamic: license-file
|
|
33
31
|
|
|
34
32
|
# PostBOUND
|
|
@@ -111,7 +109,7 @@ For DuckDB, PostBOUND uses [quacklab](https://github.com/rbergm/quacklab) hints
|
|
|
111
109
|
|
|
112
110
|
> [!NOTE]
|
|
113
111
|
> PostBOUND's database interaction is designed to be independent of a specific system (such as PostgreSQL, Oracle, ...).
|
|
114
|
-
>
|
|
112
|
+
> Currently, we focus on the Postgres (most complete) and DuckDB backends.
|
|
115
113
|
> This is due to practical reasons, mostly our own time budget and the popularity of the two systems in the optimizer research
|
|
116
114
|
> community.
|
|
117
115
|
|
|
@@ -146,16 +144,11 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
146
144
|
if not pb.qal.is_select_query(query):
|
|
147
145
|
raise pb.OptimizationError("Expected a SELECT query")
|
|
148
146
|
|
|
149
|
-
initial_table, *free_tables = random.sample(
|
|
150
|
-
list(query.tables()), k=len(query.tables())
|
|
151
|
-
)
|
|
147
|
+
initial_table, *free_tables = random.sample(list(query.tables()), k=len(query.tables()))
|
|
152
148
|
join_tree = pb.JoinTree(base_table=initial_table)
|
|
153
149
|
|
|
154
150
|
while free_tables:
|
|
155
|
-
candidates = [
|
|
156
|
-
table for table in free_tables
|
|
157
|
-
if query.joins_between(table, join_tree.tables())
|
|
158
|
-
]
|
|
151
|
+
candidates = [table for table in free_tables if query.joins_between(table, join_tree.tables())]
|
|
159
152
|
next_table = random.choice(candidates)
|
|
160
153
|
join_tree = join_tree.join_with(next_table)
|
|
161
154
|
free_tables.remove(next_table)
|
|
@@ -169,11 +162,7 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
169
162
|
pg_stats = pb.postgres.connect(config_file=".psycopg_connection_stats")
|
|
170
163
|
stats = pb.workloads.stats()
|
|
171
164
|
|
|
172
|
-
optimization_pipeline = (
|
|
173
|
-
pb.MultiStageOptimizationPipeline(pg_stats)
|
|
174
|
-
.use(RandomJoinOrder())
|
|
175
|
-
.build()
|
|
176
|
-
)
|
|
165
|
+
optimization_pipeline = pb.MultiStageOptimizationPipeline(pg_stats).use(RandomJoinOrder()).build()
|
|
177
166
|
|
|
178
167
|
# (Step 3): in this example we just compare against the native Postgres optimizer
|
|
179
168
|
# Therefore, we do not need to setup any additional optimizers.
|
|
@@ -181,9 +170,7 @@ optimization_pipeline = (
|
|
|
181
170
|
# Step 4: execute the workload.
|
|
182
171
|
# We use the QueryPreparation to prewarm the database buffer and run all
|
|
183
172
|
# queries as EXPLAIN ANALYZE.
|
|
184
|
-
query_prep = pb.bench.QueryPreparation(
|
|
185
|
-
prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"]
|
|
186
|
-
)
|
|
173
|
+
query_prep = pb.bench.QueryPreparation(prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"])
|
|
187
174
|
native_results = pb.bench.execute_workload(
|
|
188
175
|
stats,
|
|
189
176
|
on=pg_stats,
|
|
@@ -200,7 +187,6 @@ optimized_results = pb.bench.execute_workload(
|
|
|
200
187
|
progressive_output="stats-results-optimized.csv",
|
|
201
188
|
logger="tqdm",
|
|
202
189
|
)
|
|
203
|
-
|
|
204
190
|
```
|
|
205
191
|
|
|
206
192
|
## 🤬 Issues
|
|
@@ -78,7 +78,7 @@ For DuckDB, PostBOUND uses [quacklab](https://github.com/rbergm/quacklab) hints
|
|
|
78
78
|
|
|
79
79
|
> [!NOTE]
|
|
80
80
|
> PostBOUND's database interaction is designed to be independent of a specific system (such as PostgreSQL, Oracle, ...).
|
|
81
|
-
>
|
|
81
|
+
> Currently, we focus on the Postgres (most complete) and DuckDB backends.
|
|
82
82
|
> This is due to practical reasons, mostly our own time budget and the popularity of the two systems in the optimizer research
|
|
83
83
|
> community.
|
|
84
84
|
|
|
@@ -113,16 +113,11 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
113
113
|
if not pb.qal.is_select_query(query):
|
|
114
114
|
raise pb.OptimizationError("Expected a SELECT query")
|
|
115
115
|
|
|
116
|
-
initial_table, *free_tables = random.sample(
|
|
117
|
-
list(query.tables()), k=len(query.tables())
|
|
118
|
-
)
|
|
116
|
+
initial_table, *free_tables = random.sample(list(query.tables()), k=len(query.tables()))
|
|
119
117
|
join_tree = pb.JoinTree(base_table=initial_table)
|
|
120
118
|
|
|
121
119
|
while free_tables:
|
|
122
|
-
candidates = [
|
|
123
|
-
table for table in free_tables
|
|
124
|
-
if query.joins_between(table, join_tree.tables())
|
|
125
|
-
]
|
|
120
|
+
candidates = [table for table in free_tables if query.joins_between(table, join_tree.tables())]
|
|
126
121
|
next_table = random.choice(candidates)
|
|
127
122
|
join_tree = join_tree.join_with(next_table)
|
|
128
123
|
free_tables.remove(next_table)
|
|
@@ -136,11 +131,7 @@ class RandomJoinOrder(pb.JoinOrdering):
|
|
|
136
131
|
pg_stats = pb.postgres.connect(config_file=".psycopg_connection_stats")
|
|
137
132
|
stats = pb.workloads.stats()
|
|
138
133
|
|
|
139
|
-
optimization_pipeline = (
|
|
140
|
-
pb.MultiStageOptimizationPipeline(pg_stats)
|
|
141
|
-
.use(RandomJoinOrder())
|
|
142
|
-
.build()
|
|
143
|
-
)
|
|
134
|
+
optimization_pipeline = pb.MultiStageOptimizationPipeline(pg_stats).use(RandomJoinOrder()).build()
|
|
144
135
|
|
|
145
136
|
# (Step 3): in this example we just compare against the native Postgres optimizer
|
|
146
137
|
# Therefore, we do not need to setup any additional optimizers.
|
|
@@ -148,9 +139,7 @@ optimization_pipeline = (
|
|
|
148
139
|
# Step 4: execute the workload.
|
|
149
140
|
# We use the QueryPreparation to prewarm the database buffer and run all
|
|
150
141
|
# queries as EXPLAIN ANALYZE.
|
|
151
|
-
query_prep = pb.bench.QueryPreparation(
|
|
152
|
-
prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"]
|
|
153
|
-
)
|
|
142
|
+
query_prep = pb.bench.QueryPreparation(prewarm=True, analyze=True, preparatory_statements=["SET geqo TO off;"])
|
|
154
143
|
native_results = pb.bench.execute_workload(
|
|
155
144
|
stats,
|
|
156
145
|
on=pg_stats,
|
|
@@ -167,7 +156,6 @@ optimized_results = pb.bench.execute_workload(
|
|
|
167
156
|
progressive_output="stats-results-optimized.csv",
|
|
168
157
|
logger="tqdm",
|
|
169
158
|
)
|
|
170
|
-
|
|
171
159
|
```
|
|
172
160
|
|
|
173
161
|
## 🤬 Issues
|
|
@@ -8,7 +8,6 @@ from . import (
|
|
|
8
8
|
bench,
|
|
9
9
|
db,
|
|
10
10
|
duckdb,
|
|
11
|
-
mysql,
|
|
12
11
|
opt,
|
|
13
12
|
parser,
|
|
14
13
|
postgres,
|
|
@@ -135,7 +134,6 @@ __all__ = [
|
|
|
135
134
|
"db",
|
|
136
135
|
"duckdb",
|
|
137
136
|
"jointree_from_plan",
|
|
138
|
-
"mysql",
|
|
139
137
|
"operators_from_plan",
|
|
140
138
|
"opt",
|
|
141
139
|
"parameters_from_plan",
|
|
@@ -722,6 +722,34 @@ class TableReference:
|
|
|
722
722
|
"""
|
|
723
723
|
return TableReference(full_name, alias, virtual=True, schema=schema, catalog=catalog)
|
|
724
724
|
|
|
725
|
+
@staticmethod
|
|
726
|
+
def from_components(components: Iterable[str]) -> TableReference:
|
|
727
|
+
"""Creates a new table reference from a sequence of components.
|
|
728
|
+
|
|
729
|
+
The components must contain the table name as the last element, optionally preceded by the schema and catalog.
|
|
730
|
+
For example, the following sequences are valid:
|
|
731
|
+
|
|
732
|
+
- ["movie"] -> TableReference("movie")
|
|
733
|
+
- ["public", "movie"] -> TableReference("movie", schema="public")
|
|
734
|
+
- ["my_catalog", "public", "movie"] -> TableReference("movie", schema="public", catalog="my_catalog")
|
|
735
|
+
|
|
736
|
+
If the components contain any other number of elements, an error is raised.
|
|
737
|
+
"""
|
|
738
|
+
if not isinstance(components, Sequence):
|
|
739
|
+
components = list(components)
|
|
740
|
+
|
|
741
|
+
match len(components):
|
|
742
|
+
case 1:
|
|
743
|
+
return TableReference(components[0])
|
|
744
|
+
case 2:
|
|
745
|
+
schema, name = components
|
|
746
|
+
return TableReference(name, schema=schema)
|
|
747
|
+
case 3:
|
|
748
|
+
catalog, schema, name = components
|
|
749
|
+
return TableReference(name, schema=schema, catalog=catalog)
|
|
750
|
+
case _:
|
|
751
|
+
raise ValueError(f"Could not parse table reference with components {components}")
|
|
752
|
+
|
|
725
753
|
def __init__(
|
|
726
754
|
self,
|
|
727
755
|
full_name: str,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from IPython.core.getipython import get_ipython
|
|
3
4
|
from IPython.lib import pretty
|
|
4
5
|
|
|
5
6
|
from ._hints import JoinTree, PhysicalOperatorAssignment, PlanParameterization
|
|
6
7
|
from ._qep import QueryPlan
|
|
7
|
-
from .qal import SqlQuery, format_quick
|
|
8
|
+
from .qal import SelectStatement, SetQuery, SqlQuery, format_quick
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def pretty_print_query(query: SqlQuery, p: pretty.PrettyPrinter, cycle: bool) -> None:
|
|
@@ -43,8 +44,16 @@ def pretty_print_plan_params(parameters: PlanParameterization, p: pretty.PrettyP
|
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
def setup_pretty_printers() -> None:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
shell = get_ipython()
|
|
48
|
+
if shell is None:
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
plain_formatter = shell.display_formatter.formatters["text/plain"]
|
|
52
|
+
|
|
53
|
+
plain_formatter.for_type(SqlQuery, pretty_print_query)
|
|
54
|
+
plain_formatter.for_type(SelectStatement, pretty_print_query)
|
|
55
|
+
plain_formatter.for_type(SetQuery, pretty_print_query)
|
|
56
|
+
plain_formatter.for_type(QueryPlan, pretty_print_plan)
|
|
57
|
+
plain_formatter.for_type(JoinTree, pretty_print_join_tree)
|
|
58
|
+
plain_formatter.for_type(PhysicalOperatorAssignment, pretty_print_physical_ops)
|
|
59
|
+
plain_formatter.for_type(PlanParameterization, pretty_print_plan_params)
|
|
@@ -30,7 +30,6 @@ Supported Systems
|
|
|
30
30
|
-----------------
|
|
31
31
|
|
|
32
32
|
PostBOUND ships database backends for PostgreSQL and DuckDB out of the box. Both are available in dedicated top-level modules.
|
|
33
|
-
In addition, there is rudimentary support for MySQL, but this backend is not actively maintained.
|
|
34
33
|
|
|
35
34
|
Users can implement their own database backends for specific systems by subclassing `Database` and the other relevant classes.
|
|
36
35
|
|
|
@@ -79,6 +78,7 @@ from __future__ import annotations
|
|
|
79
78
|
|
|
80
79
|
from ._cache import ResultCache
|
|
81
80
|
from ._db import (
|
|
81
|
+
ColumnInfo,
|
|
82
82
|
Connection,
|
|
83
83
|
Cursor,
|
|
84
84
|
Database,
|
|
@@ -94,10 +94,12 @@ from ._db import (
|
|
|
94
94
|
MostCommonValues,
|
|
95
95
|
OptimizerInterface,
|
|
96
96
|
PrewarmingSupport,
|
|
97
|
+
PrimaryKeyRef,
|
|
97
98
|
ResultRow,
|
|
98
99
|
ResultSet,
|
|
99
100
|
StatisticsCatalog,
|
|
100
101
|
StopwatchSupport,
|
|
102
|
+
TableInfo,
|
|
101
103
|
TimeoutSupport,
|
|
102
104
|
UnsupportedDatabaseFeatureError,
|
|
103
105
|
current_database,
|
|
@@ -123,6 +125,7 @@ value.
|
|
|
123
125
|
"""
|
|
124
126
|
|
|
125
127
|
__all__ = [
|
|
128
|
+
"ColumnInfo",
|
|
126
129
|
"Connection",
|
|
127
130
|
"Cursor",
|
|
128
131
|
"Database",
|
|
@@ -139,11 +142,13 @@ __all__ = [
|
|
|
139
142
|
"OptimizerInterface",
|
|
140
143
|
"PreciseStatistics",
|
|
141
144
|
"PrewarmingSupport",
|
|
145
|
+
"PrimaryKeyRef",
|
|
142
146
|
"ResultCache",
|
|
143
147
|
"ResultRow",
|
|
144
148
|
"ResultSet",
|
|
145
149
|
"StatisticsCatalog",
|
|
146
150
|
"StopwatchSupport",
|
|
151
|
+
"TableInfo",
|
|
147
152
|
"TimeoutSupport",
|
|
148
153
|
"UnsupportedDatabaseFeatureError",
|
|
149
154
|
"current_database",
|