jupyter-duckdb 1.2.0.1__py3-none-any.whl → 1.2.0.3__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/db/Table.py +8 -0
- duckdb_kernel/db/implementation/duckdb/Connection.py +19 -12
- duckdb_kernel/db/implementation/postgres/Connection.py +19 -11
- duckdb_kernel/db/implementation/sqlite/Connection.py +4 -2
- duckdb_kernel/kernel.py +3 -3
- duckdb_kernel/parser/elements/binary/ConditionalSet.py +1 -1
- {jupyter_duckdb-1.2.0.1.dist-info → jupyter_duckdb-1.2.0.3.dist-info}/METADATA +1 -1
- {jupyter_duckdb-1.2.0.1.dist-info → jupyter_duckdb-1.2.0.3.dist-info}/RECORD +10 -10
- {jupyter_duckdb-1.2.0.1.dist-info → jupyter_duckdb-1.2.0.3.dist-info}/WHEEL +0 -0
- {jupyter_duckdb-1.2.0.1.dist-info → jupyter_duckdb-1.2.0.3.dist-info}/top_level.txt +0 -0
duckdb_kernel/db/Table.py
CHANGED
|
@@ -14,11 +14,19 @@ class Table:
|
|
|
14
14
|
self.unique_keys: List[Constraint] = []
|
|
15
15
|
self.foreign_keys: List[ForeignKey] = []
|
|
16
16
|
|
|
17
|
+
@staticmethod
|
|
18
|
+
def normalize_name(name: str) -> str:
|
|
19
|
+
return name.lower()
|
|
20
|
+
|
|
17
21
|
@property
|
|
18
22
|
def id(self) -> str:
|
|
19
23
|
name = re.sub(r'[^A-Za-z]', '_', self.name)
|
|
20
24
|
return f'table_{name}'
|
|
21
25
|
|
|
26
|
+
@property
|
|
27
|
+
def normalized_name(self) -> str:
|
|
28
|
+
return self.normalize_name(self.name)
|
|
29
|
+
|
|
22
30
|
def get_column(self, name: str) -> "Column":
|
|
23
31
|
for column in self.columns:
|
|
24
32
|
if column.name == name:
|
|
@@ -59,7 +59,7 @@ class Connection(Base):
|
|
|
59
59
|
WHERE table_type == 'BASE TABLE'
|
|
60
60
|
''').fetchall():
|
|
61
61
|
table = Table(table_name)
|
|
62
|
-
tables[
|
|
62
|
+
tables[table.normalized_name] = table
|
|
63
63
|
|
|
64
64
|
# Get column names and data types for each table.
|
|
65
65
|
for table_name, column_name, data_type, is_nullable in self.con.execute('''
|
|
@@ -71,8 +71,9 @@ class Connection(Base):
|
|
|
71
71
|
FROM information_schema.columns
|
|
72
72
|
ORDER BY ordinal_position ASC
|
|
73
73
|
''').fetchall():
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
75
|
+
if normalized_table_name in tables:
|
|
76
|
+
table = tables[normalized_table_name]
|
|
76
77
|
|
|
77
78
|
column = Column(table, column_name, data_type, is_nullable == 'YES')
|
|
78
79
|
table.columns.append(column)
|
|
@@ -88,10 +89,12 @@ class Connection(Base):
|
|
|
88
89
|
ORDER BY constraint_index ASC
|
|
89
90
|
''').fetchall():
|
|
90
91
|
# get table
|
|
91
|
-
|
|
92
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
93
|
+
|
|
94
|
+
if normalized_table_name not in tables:
|
|
92
95
|
raise AssertionError(f'unknown table {table_name} for constraint {constraint_index}')
|
|
93
96
|
|
|
94
|
-
table = tables[
|
|
97
|
+
table = tables[normalized_table_name]
|
|
95
98
|
|
|
96
99
|
# store constraint
|
|
97
100
|
if constraint_index in constraints:
|
|
@@ -102,7 +105,7 @@ class Connection(Base):
|
|
|
102
105
|
table,
|
|
103
106
|
tuple(table.get_column(c) for c in constraint_columns)
|
|
104
107
|
)
|
|
105
|
-
constraints[(
|
|
108
|
+
constraints[(normalized_table_name, *constraint_columns)] = constraint
|
|
106
109
|
|
|
107
110
|
# store key
|
|
108
111
|
if table.primary_key is not None:
|
|
@@ -121,10 +124,12 @@ class Connection(Base):
|
|
|
121
124
|
ORDER BY constraint_index ASC
|
|
122
125
|
''').fetchall():
|
|
123
126
|
# get table
|
|
124
|
-
|
|
127
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
128
|
+
|
|
129
|
+
if normalized_table_name not in tables:
|
|
125
130
|
raise AssertionError(f'unknown table {table_name} for constraint {constraint_index}')
|
|
126
131
|
|
|
127
|
-
table = tables[
|
|
132
|
+
table = tables[normalized_table_name]
|
|
128
133
|
|
|
129
134
|
# store constraint
|
|
130
135
|
if constraint_index in constraints:
|
|
@@ -135,7 +140,7 @@ class Connection(Base):
|
|
|
135
140
|
table,
|
|
136
141
|
tuple(table.get_column(c) for c in constraint_columns)
|
|
137
142
|
)
|
|
138
|
-
constraints[(
|
|
143
|
+
constraints[(normalized_table_name, *constraint_columns)] = constraint
|
|
139
144
|
|
|
140
145
|
# store key
|
|
141
146
|
table.unique_keys.append(constraint)
|
|
@@ -153,13 +158,15 @@ class Connection(Base):
|
|
|
153
158
|
ORDER BY constraint_index ASC
|
|
154
159
|
''').fetchall():
|
|
155
160
|
# get table
|
|
156
|
-
|
|
161
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
162
|
+
|
|
163
|
+
if normalized_table_name not in tables:
|
|
157
164
|
raise AssertionError(f'unknown table {table_name} for constraint {constraint_index}')
|
|
158
165
|
|
|
159
|
-
table = tables[
|
|
166
|
+
table = tables[normalized_table_name]
|
|
160
167
|
|
|
161
168
|
# lookup constraint
|
|
162
|
-
constraint_key = (referenced_table, *referenced_column_names)
|
|
169
|
+
constraint_key = (Table.normalize_name(referenced_table), *referenced_column_names)
|
|
163
170
|
if constraint_key not in constraints:
|
|
164
171
|
raise AssertionError(f'constraint with key {constraint_key} not discovered previously')
|
|
165
172
|
|
|
@@ -88,7 +88,7 @@ class Connection(Base):
|
|
|
88
88
|
WHERE table_schema='public' AND table_type='BASE TABLE'
|
|
89
89
|
''').fetchall():
|
|
90
90
|
table = Table(table_name)
|
|
91
|
-
tables[
|
|
91
|
+
tables[table.normalized_name] = table
|
|
92
92
|
|
|
93
93
|
# Get column names and data types for each table.
|
|
94
94
|
for table_name, column_name, data_type, is_nullable in self.con.execute('''
|
|
@@ -100,8 +100,9 @@ class Connection(Base):
|
|
|
100
100
|
FROM information_schema.columns
|
|
101
101
|
ORDER BY ordinal_position ASC
|
|
102
102
|
''').fetchall():
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
104
|
+
if normalized_table_name in tables:
|
|
105
|
+
table = tables[normalized_table_name]
|
|
105
106
|
|
|
106
107
|
column = Column(table, column_name, data_type, is_nullable == 'YES')
|
|
107
108
|
table.columns.append(column)
|
|
@@ -126,10 +127,12 @@ class Connection(Base):
|
|
|
126
127
|
|
|
127
128
|
for constraint_name, (table_name, column_names) in constraints_dict.items():
|
|
128
129
|
# get table
|
|
129
|
-
|
|
130
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
131
|
+
|
|
132
|
+
if normalized_table_name not in tables:
|
|
130
133
|
raise AssertionError(f'unknown table {table_name} for constraint {constraint_index}')
|
|
131
134
|
|
|
132
|
-
table = tables[
|
|
135
|
+
table = tables[normalized_table_name]
|
|
133
136
|
|
|
134
137
|
# store constraint
|
|
135
138
|
constraint = Constraint(
|
|
@@ -166,10 +169,12 @@ class Connection(Base):
|
|
|
166
169
|
|
|
167
170
|
for constraint_name, (table_name, column_names) in constraints_dict.items():
|
|
168
171
|
# get table
|
|
169
|
-
|
|
172
|
+
normalized_table_name = Table.normalize_name(table_name)
|
|
173
|
+
|
|
174
|
+
if normalized_table_name not in tables:
|
|
170
175
|
raise AssertionError(f'unknown table {table_name} for constraint {constraint_index}')
|
|
171
176
|
|
|
172
|
-
table = tables[
|
|
177
|
+
table = tables[normalized_table_name]
|
|
173
178
|
|
|
174
179
|
# store constraint
|
|
175
180
|
constraint = Constraint(
|
|
@@ -197,20 +202,23 @@ class Connection(Base):
|
|
|
197
202
|
raise AssertionError(f'could not parse foreign key definitions for table {source_table_name}')
|
|
198
203
|
|
|
199
204
|
source_table_name = strip_delimiters(source_table_name)
|
|
205
|
+
normalized_source_table_name = Table.normalize_name(source_table_name)
|
|
200
206
|
source_table_column_names = [strip_delimiters(c) for c in match.group(1).split(',')]
|
|
207
|
+
|
|
201
208
|
target_table_name = strip_delimiters(match.group(2))
|
|
209
|
+
normalized_target_table_name = Table.normalize_name(target_table_name)
|
|
202
210
|
target_table_column_names = [strip_delimiters(c) for c in match.group(3).split(',')]
|
|
203
211
|
|
|
204
212
|
# get tables
|
|
205
|
-
if
|
|
213
|
+
if normalized_source_table_name not in tables:
|
|
206
214
|
raise AssertionError(f'unknown table {source_table_name} for foreign key {fk_name}')
|
|
207
215
|
|
|
208
|
-
source_table = tables[
|
|
216
|
+
source_table = tables[normalized_source_table_name]
|
|
209
217
|
|
|
210
|
-
if
|
|
218
|
+
if normalized_target_table_name not in tables:
|
|
211
219
|
raise AssertionError(f'unknown table {target_table_name} for foreign key {fk_name}')
|
|
212
220
|
|
|
213
|
-
target_table = tables[
|
|
221
|
+
target_table = tables[normalized_target_table_name]
|
|
214
222
|
|
|
215
223
|
# store constraint
|
|
216
224
|
constraint = Constraint(
|
|
@@ -61,7 +61,7 @@ class Connection(Base):
|
|
|
61
61
|
WHERE type ='table' AND name NOT LIKE 'sqlite_%';
|
|
62
62
|
''').fetchall():
|
|
63
63
|
table = Table(table_name)
|
|
64
|
-
tables[
|
|
64
|
+
tables[table.normalized_name] = table
|
|
65
65
|
|
|
66
66
|
# Get column names and data types for each table.
|
|
67
67
|
for table_name, table in tables.items():
|
|
@@ -174,8 +174,10 @@ class Connection(Base):
|
|
|
174
174
|
current_targets = []
|
|
175
175
|
|
|
176
176
|
# add columns to parse later
|
|
177
|
+
normalized_to_table_name = Table.normalize_name(to_table_name)
|
|
178
|
+
|
|
177
179
|
current_sources.append(table.get_column(from_col))
|
|
178
|
-
current_targets.append(tables[
|
|
180
|
+
current_targets.append(tables[normalized_to_table_name].get_column(to_col))
|
|
179
181
|
|
|
180
182
|
if len(current_sources) > 0:
|
|
181
183
|
store()
|
duckdb_kernel/kernel.py
CHANGED
|
@@ -9,7 +9,7 @@ from typing import Optional, Dict, List, Tuple
|
|
|
9
9
|
|
|
10
10
|
from ipykernel.kernelbase import Kernel
|
|
11
11
|
|
|
12
|
-
from .db import Connection, DatabaseError
|
|
12
|
+
from .db import Connection, DatabaseError, Table
|
|
13
13
|
from .db.error import *
|
|
14
14
|
from .magics import *
|
|
15
15
|
from .parser import RAParser, DCParser
|
|
@@ -313,7 +313,7 @@ class DuckDBKernel(Kernel):
|
|
|
313
313
|
for dc in data_columns:
|
|
314
314
|
found = 0
|
|
315
315
|
for i, rc in enumerate(result_columns):
|
|
316
|
-
if dc == rc:
|
|
316
|
+
if dc.lower() == rc.lower():
|
|
317
317
|
column_order.append(i)
|
|
318
318
|
found += 1
|
|
319
319
|
|
|
@@ -404,7 +404,7 @@ class DuckDBKernel(Kernel):
|
|
|
404
404
|
whitelist = set()
|
|
405
405
|
|
|
406
406
|
# split and strip names
|
|
407
|
-
names = [n.strip() for n in re.split(r'[, \t]', only)]
|
|
407
|
+
names = [Table.normalize_name(n.strip()) for n in re.split(r'[, \t]', only)]
|
|
408
408
|
|
|
409
409
|
# add initial tables to result set
|
|
410
410
|
for name in names:
|
|
@@ -116,7 +116,7 @@ class ConditionalSet:
|
|
|
116
116
|
underscore_regex = re.compile(r'_{1,}')
|
|
117
117
|
|
|
118
118
|
for operand_i, operand in enumerate(dc_operands):
|
|
119
|
-
source_columns = tables[operand.relation].columns
|
|
119
|
+
source_columns = tables[Table.normalize_name(operand.relation)].columns
|
|
120
120
|
|
|
121
121
|
# Raise an exception if the given number of operands does not match
|
|
122
122
|
# the number of attributes in the relation.
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
duckdb_kernel/__init__.py,sha256=6auU6zeJrsA4fxPSr2PYamS8fG-SMXTn5YQFXF2cseo,33
|
|
2
2
|
duckdb_kernel/__main__.py,sha256=Z3GwHEBWoQjNm2Y84ijnbA0Lk66L7nsFREuqhZ_ptk0,165
|
|
3
3
|
duckdb_kernel/kernel.json,sha256=_7E8Ci2FSdCvnzCjsOaue8QE8AvpS5JLQuxORO5IGtA,127
|
|
4
|
-
duckdb_kernel/kernel.py,sha256=
|
|
4
|
+
duckdb_kernel/kernel.py,sha256=Td6S4qWDC9uuqgAhSllXwR-JHHdnGfT14RHkfYLzXxI,19441
|
|
5
5
|
duckdb_kernel/db/Column.py,sha256=GM5P6sFdlYK92hiKln5-6038gIDOTxh1AYbR4kiga_w,559
|
|
6
6
|
duckdb_kernel/db/Connection.py,sha256=5pH-CwGh-r9Q2QwJKGSxvoINBU-sqmvZyG4Q1digfeE,599
|
|
7
7
|
duckdb_kernel/db/Constraint.py,sha256=1YgUHk7s8mHCVedbcuJKyXDykj7_ybbwT3Dk9p2VMis,287
|
|
8
8
|
duckdb_kernel/db/DatabaseError.py,sha256=43zl8yym1f-fxH_UtGIbWnDnBE_TRwr9aCziY9t40QY,41
|
|
9
9
|
duckdb_kernel/db/ForeignKey.py,sha256=iurUAXwTwSIpLXsL0B7BA8jqDTfW4_wkeHxoqQbZwiU,470
|
|
10
|
-
duckdb_kernel/db/Table.py,sha256=
|
|
10
|
+
duckdb_kernel/db/Table.py,sha256=HfvGX54kD_XvmLApYSmxtTQNvz2YYaaUNpm4e8dSOVY,934
|
|
11
11
|
duckdb_kernel/db/__init__.py,sha256=PKQYQDCW7VQYxmzhQK6A0Qloka9FdMfeFQMfY-CjBSA,198
|
|
12
12
|
duckdb_kernel/db/error/EmptyResultError.py,sha256=N9Oxi2HDZBKaRQsfRsWpJJGOYX4BjdQqWOU-XvzUzNY,92
|
|
13
13
|
duckdb_kernel/db/error/__init__.py,sha256=oHfhfbcfyTJ3pAPN835omdQcebvJTauuULFx5gm9rq4,47
|
|
14
|
-
duckdb_kernel/db/implementation/duckdb/Connection.py,sha256=
|
|
14
|
+
duckdb_kernel/db/implementation/duckdb/Connection.py,sha256=4zBgK9xYSV2m7tSl81kLOqGhByP7UhyCZxDuLVpZz7c,6817
|
|
15
15
|
duckdb_kernel/db/implementation/duckdb/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
|
|
16
|
-
duckdb_kernel/db/implementation/postgres/Connection.py,sha256=
|
|
16
|
+
duckdb_kernel/db/implementation/postgres/Connection.py,sha256=39wv-mvKHdu4u_ADFiSbAvGMVEs3FtuzRYIH4uzJ-pw,9307
|
|
17
17
|
duckdb_kernel/db/implementation/postgres/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
|
|
18
18
|
duckdb_kernel/db/implementation/postgres/util.py,sha256=4nr1mqXhlwkMVXbJSfJ7dRlUm6UskpvgKApe7GRwmBI,281
|
|
19
|
-
duckdb_kernel/db/implementation/sqlite/Connection.py,sha256=
|
|
19
|
+
duckdb_kernel/db/implementation/sqlite/Connection.py,sha256=L-aSUuN_7Z-hc5wczLjap2Xu-Vv6-dXmwXcN_WE8o98,6994
|
|
20
20
|
duckdb_kernel/db/implementation/sqlite/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
|
|
21
21
|
duckdb_kernel/magics/MagicCommand.py,sha256=OoQ6j4cNtIYjaK4MPVzJyv1eYTNu4_a7qoRx-5G3Hg0,2346
|
|
22
22
|
duckdb_kernel/magics/MagicCommandCallback.py,sha256=r1kkJyRR7sZnrnlMH3w4bGqDAJL-BVTIB4-Kn66ynlM,764
|
|
@@ -40,7 +40,7 @@ duckdb_kernel/parser/elements/__init__.py,sha256=4DA2M43hh9d1fZb5Z6YnTTI-IBkDyhC
|
|
|
40
40
|
duckdb_kernel/parser/elements/binary/Add.py,sha256=XGkZMfab01huk9EaI6JUfzkd2STbV1C_-TyC2guKE8I,190
|
|
41
41
|
duckdb_kernel/parser/elements/binary/And.py,sha256=0jgetTG8yo5TJSeK70Kj-PI9ERyek1eyMQXX5HBxa4Y,274
|
|
42
42
|
duckdb_kernel/parser/elements/binary/ArrowLeft.py,sha256=u4fZSoyT9lfvWXBwuhUl4DdjVZAOqyVIKmMVbpElLD4,203
|
|
43
|
-
duckdb_kernel/parser/elements/binary/ConditionalSet.py,sha256=
|
|
43
|
+
duckdb_kernel/parser/elements/binary/ConditionalSet.py,sha256=4KzvUTls2bodJw9ejCKx8se32PR5VFJbVupDZVx2NHE,16671
|
|
44
44
|
duckdb_kernel/parser/elements/binary/Cross.py,sha256=jVY3cvD6qDWZkJ7q74lFUPO2VdDt4aAjdk2YAfg-ZC4,687
|
|
45
45
|
duckdb_kernel/parser/elements/binary/Difference.py,sha256=ZVRgJHYVMOFwnc97oPvGtKvLvHsjSCsn2Aao6ymxY8Y,742
|
|
46
46
|
duckdb_kernel/parser/elements/binary/Divide.py,sha256=d7mzaOeRYSRO1F-2IHsv_C939TuYtLppbf4-5GSRJXs,265
|
|
@@ -76,7 +76,7 @@ duckdb_kernel/visualization/Drawer.py,sha256=D0LkiGMvuJ2v6cQSg_axLTGaM4VXAJEQJAy
|
|
|
76
76
|
duckdb_kernel/visualization/RATreeDrawer.py,sha256=j-Vy1zpYMzwZ3CsphyfPW-J7ou9a9tM6aXXgAlQTgDI,2128
|
|
77
77
|
duckdb_kernel/visualization/SchemaDrawer.py,sha256=9K-TUUmyeGdMYMTFQJ7evIU3p8p2KyMKeizUc7-y8co,3015
|
|
78
78
|
duckdb_kernel/visualization/__init__.py,sha256=5eMJmxJ01XAXcgWDn3t70eSZF2PGaXdNo6GK-x-0H3s,78
|
|
79
|
-
jupyter_duckdb-1.2.0.
|
|
80
|
-
jupyter_duckdb-1.2.0.
|
|
81
|
-
jupyter_duckdb-1.2.0.
|
|
82
|
-
jupyter_duckdb-1.2.0.
|
|
79
|
+
jupyter_duckdb-1.2.0.3.dist-info/METADATA,sha256=O4AGOi_-WpenZIFXf6ZGNNPFGDWAHTNOYOA2CdEB4g0,7980
|
|
80
|
+
jupyter_duckdb-1.2.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
81
|
+
jupyter_duckdb-1.2.0.3.dist-info/top_level.txt,sha256=KvRRPMnmkQNuhyBsXoPmwyt26LRDp0O-0HN6u0Dm5jA,14
|
|
82
|
+
jupyter_duckdb-1.2.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|