jupyter-duckdb 0.9.2.1.dev202311200802__py3-none-any.whl → 0.9.2.2__py3-none-any.whl
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.
- duckdb_kernel/parser/elements/RAOperand.py +5 -2
- duckdb_kernel/parser/elements/binary/ConditionalSet.py +29 -8
- {jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/METADATA +1 -1
- {jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/RECORD +6 -6
- {jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/WHEEL +1 -1
- {jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/top_level.txt +0 -0
|
@@ -22,10 +22,13 @@ class RAOperand(RAElement):
|
|
|
22
22
|
yield
|
|
23
23
|
|
|
24
24
|
def to_sql(self, tables: Dict[str, Table]) -> Tuple[str, RenamableColumnList]:
|
|
25
|
-
|
|
25
|
+
table_keys = {key.lower(): key for key in tables}
|
|
26
|
+
relation_lower = self.relation.lower()
|
|
27
|
+
|
|
28
|
+
if relation_lower not in table_keys:
|
|
26
29
|
raise AssertionError(f'unknown relation {self.relation}')
|
|
27
30
|
|
|
28
|
-
cols = RenamableColumnList.from_iter(tables[
|
|
31
|
+
cols = RenamableColumnList.from_iter(tables[table_keys[relation_lower]].columns)
|
|
29
32
|
column_names = ', '.join(c.rename() for c in cols)
|
|
30
33
|
|
|
31
34
|
return f'SELECT DISTINCT {column_names} FROM {self.relation}', cols
|
|
@@ -149,9 +149,9 @@ class ConditionalSet:
|
|
|
149
149
|
# names for the attributes. We store the related operands and the join conditions.
|
|
150
150
|
# Furthermore, `select_columns` contains a mapping from column names to a part of
|
|
151
151
|
# a "select as" statement and joined_columns is a list of all columns that were
|
|
152
|
-
# used for joins, so the resulting sql
|
|
152
|
+
# used for joins, so the resulting sql statements do not become ambiguous if they
|
|
153
153
|
# are used for filtering.
|
|
154
|
-
positive_joins: List[Tuple[str, str, List[str]]] = []
|
|
154
|
+
positive_joins: List[Tuple[str, str, Optional[List[str]]]] = []
|
|
155
155
|
select_columns: Dict[str, str] = {}
|
|
156
156
|
joined_columns: RenamableColumnList = RenamableColumnList()
|
|
157
157
|
|
|
@@ -206,9 +206,22 @@ class ConditionalSet:
|
|
|
206
206
|
already_joined.add(join_tuple)
|
|
207
207
|
discovered_joins += 1
|
|
208
208
|
|
|
209
|
-
# If no
|
|
209
|
+
# If no common attributes were discovered using this table,
|
|
210
|
+
# a cross join is used instead.
|
|
210
211
|
if discovered_joins == 0:
|
|
211
|
-
|
|
212
|
+
# Find any other table for the cross join, so the joins
|
|
213
|
+
# can later be constructed.
|
|
214
|
+
for right_name, _, _ in relevant_positive:
|
|
215
|
+
if left_name != right_name:
|
|
216
|
+
break
|
|
217
|
+
else:
|
|
218
|
+
raise AssertionError(f'could not build join for relation {left_name}')
|
|
219
|
+
|
|
220
|
+
join_tuple = min(left_name, right_name), max(left_name, right_name)
|
|
221
|
+
|
|
222
|
+
# Store the join with a join condition that is None.
|
|
223
|
+
positive_joins.append((left_name, right_name, None))
|
|
224
|
+
already_joined.add(join_tuple)
|
|
212
225
|
|
|
213
226
|
# Last but not least we need to include the "negative" joins. They only
|
|
214
227
|
# remove tuples and never add any attributes, so we only track the
|
|
@@ -249,12 +262,17 @@ class ConditionalSet:
|
|
|
249
262
|
for _, target_name, join_condition in positive_joins:
|
|
250
263
|
if target_name not in all_positive_conditions:
|
|
251
264
|
all_positive_conditions[target_name] = []
|
|
252
|
-
|
|
265
|
+
if join_condition is not None:
|
|
266
|
+
all_positive_conditions[target_name].extend(join_condition)
|
|
253
267
|
|
|
254
|
-
sorted_positive_joins: List[Tuple[str, str, str]] = []
|
|
268
|
+
sorted_positive_joins: List[Tuple[str, str, Optional[str]]] = []
|
|
255
269
|
while len(used_relations) < len(relevant_positive):
|
|
256
270
|
for source_name, target_name, _ in positive_joins:
|
|
257
|
-
|
|
271
|
+
apc = all_positive_conditions[target_name]
|
|
272
|
+
if len(apc) == 0:
|
|
273
|
+
join_condition = None
|
|
274
|
+
else:
|
|
275
|
+
join_condition = ' AND '.join(apc)
|
|
258
276
|
|
|
259
277
|
if source_name in used_relations and target_name not in used_relations:
|
|
260
278
|
sorted_positive_joins.append((source_name, target_name, join_condition))
|
|
@@ -308,7 +326,10 @@ class ConditionalSet:
|
|
|
308
326
|
sql_tables = table_statements[relevant_positive[0][0]]
|
|
309
327
|
for _, target_name, join_condition in sorted_positive_joins:
|
|
310
328
|
target_table_stmt = table_statements[target_name]
|
|
311
|
-
|
|
329
|
+
if join_condition is None:
|
|
330
|
+
sql_tables += f' CROSS JOIN {target_table_stmt}'
|
|
331
|
+
else:
|
|
332
|
+
sql_tables += f' JOIN {target_table_stmt} ON {join_condition}'
|
|
312
333
|
for _, target_name, join_condition, _ in sorted_negative_joins:
|
|
313
334
|
target_table_stmt = table_statements[target_name]
|
|
314
335
|
sql_tables += f' LEFT JOIN {target_table_stmt} ON {join_condition}'
|
{jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/RECORD
RENAMED
|
@@ -28,14 +28,14 @@ duckdb_kernel/parser/elements/LogicOperand.py,sha256=B9NvriloQE5eP734dNMZBZwrdaa
|
|
|
28
28
|
duckdb_kernel/parser/elements/LogicOperator.py,sha256=lkM4TAGkXUhsO4w4PLKVA0bgCRGPQQFpNA1FcWWOW9Q,1028
|
|
29
29
|
duckdb_kernel/parser/elements/RABinaryOperator.py,sha256=XN41stGc1e-a4dZ1AQVtQ3lEgjUGNt3dMfYXp85LEeE,538
|
|
30
30
|
duckdb_kernel/parser/elements/RAElement.py,sha256=gFnByFmDR34mo4nJa432c8tCE9AMPv9Gjn2fT3zL7_Y,1468
|
|
31
|
-
duckdb_kernel/parser/elements/RAOperand.py,sha256=
|
|
31
|
+
duckdb_kernel/parser/elements/RAOperand.py,sha256=pghnTYCrrT6MkvynJRgVFPRoMvxIGNB3FTjaq-uCpDQ,1078
|
|
32
32
|
duckdb_kernel/parser/elements/RAOperator.py,sha256=rtqMFBIBBqT-Bwg7Qm4WQwbDrE28Nb74F_7XMeR3ks4,255
|
|
33
33
|
duckdb_kernel/parser/elements/RAUnaryOperator.py,sha256=XC1nphkSm88JaEu5V_HKnb_8JNoeBfE3EvNL4o0qh2c,654
|
|
34
34
|
duckdb_kernel/parser/elements/__init__.py,sha256=4DA2M43hh9d1fZb5Z6YnTTI-IBkDyhChSF5L9X3EA-s,547
|
|
35
35
|
duckdb_kernel/parser/elements/binary/Add.py,sha256=XGkZMfab01huk9EaI6JUfzkd2STbV1C_-TyC2guKE8I,190
|
|
36
36
|
duckdb_kernel/parser/elements/binary/And.py,sha256=0jgetTG8yo5TJSeK70Kj-PI9ERyek1eyMQXX5HBxa4Y,274
|
|
37
37
|
duckdb_kernel/parser/elements/binary/ArrowLeft.py,sha256=u4fZSoyT9lfvWXBwuhUl4DdjVZAOqyVIKmMVbpElLD4,203
|
|
38
|
-
duckdb_kernel/parser/elements/binary/ConditionalSet.py,sha256=
|
|
38
|
+
duckdb_kernel/parser/elements/binary/ConditionalSet.py,sha256=wTum6yIspWjH3b_IDZBfD1DzG_xwKzpD_To9jBann_A,16643
|
|
39
39
|
duckdb_kernel/parser/elements/binary/Cross.py,sha256=jVY3cvD6qDWZkJ7q74lFUPO2VdDt4aAjdk2YAfg-ZC4,687
|
|
40
40
|
duckdb_kernel/parser/elements/binary/Difference.py,sha256=2oCdVm2dgd4Xh6ysLqqv1JgfNS_Bjtd8oA-kNBoFLf0,743
|
|
41
41
|
duckdb_kernel/parser/elements/binary/Divide.py,sha256=d7mzaOeRYSRO1F-2IHsv_C939TuYtLppbf4-5GSRJXs,265
|
|
@@ -70,7 +70,7 @@ duckdb_kernel/visualization/Drawer.py,sha256=D0LkiGMvuJ2v6cQSg_axLTGaM4VXAJEQJAy
|
|
|
70
70
|
duckdb_kernel/visualization/RATreeDrawer.py,sha256=j-Vy1zpYMzwZ3CsphyfPW-J7ou9a9tM6aXXgAlQTgDI,2128
|
|
71
71
|
duckdb_kernel/visualization/SchemaDrawer.py,sha256=fkp7tnyfzKQBXVI6X7efAvT8lczi_XlA7Hc_rhP_47s,2955
|
|
72
72
|
duckdb_kernel/visualization/__init__.py,sha256=5eMJmxJ01XAXcgWDn3t70eSZF2PGaXdNo6GK-x-0H3s,78
|
|
73
|
-
jupyter_duckdb-0.9.2.
|
|
74
|
-
jupyter_duckdb-0.9.2.
|
|
75
|
-
jupyter_duckdb-0.9.2.
|
|
76
|
-
jupyter_duckdb-0.9.2.
|
|
73
|
+
jupyter_duckdb-0.9.2.2.dist-info/METADATA,sha256=fWbL4a6-vaQgGYki40Ur5fKVciw3Cizx2L-thNGVtX4,7748
|
|
74
|
+
jupyter_duckdb-0.9.2.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
75
|
+
jupyter_duckdb-0.9.2.2.dist-info/top_level.txt,sha256=KvRRPMnmkQNuhyBsXoPmwyt26LRDp0O-0HN6u0Dm5jA,14
|
|
76
|
+
jupyter_duckdb-0.9.2.2.dist-info/RECORD,,
|
{jupyter_duckdb-0.9.2.1.dev202311200802.dist-info → jupyter_duckdb-0.9.2.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|