jupyter-duckdb 1.2.7__tar.gz → 1.2.101__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.
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/PKG-INFO +2 -2
- jupyter_duckdb-1.2.101/setup.py +52 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/kernel.py +86 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/MagicCommandHandler.py +9 -1
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Difference.py +1 -1
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Divide.py +1 -1
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Division.py +0 -4
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/FullOuterJoin.py +10 -3
- jupyter_duckdb-1.2.101/src/duckdb_kernel/tests/__init__.py +76 -0
- {jupyter_duckdb-1.2.7/test → jupyter_duckdb-1.2.101/src/duckdb_kernel/tests}/test_dc.py +141 -22
- {jupyter_duckdb-1.2.7/test → jupyter_duckdb-1.2.101/src/duckdb_kernel/tests}/test_ra.py +179 -53
- jupyter_duckdb-1.2.101/src/duckdb_kernel/visualization/Plotly.py +154 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/visualization/__init__.py +1 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/jupyter_duckdb.egg-info/PKG-INFO +2 -2
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/jupyter_duckdb.egg-info/SOURCES.txt +7 -5
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/jupyter_duckdb.egg-info/requires.txt +1 -1
- jupyter_duckdb-1.2.7/setup.py +0 -50
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/README.md +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/setup.cfg +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/__main__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/Column.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/Connection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/Constraint.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/DatabaseError.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/ForeignKey.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/Table.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/error/EmptyResultError.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/error/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/duckdb/Connection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/duckdb/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/postgres/Connection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/postgres/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/postgres/util.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/sqlite/Connection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/db/implementation/sqlite/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/kernel.json +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/MagicCommand.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/MagicCommandCallback.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/MagicCommandException.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/StringWrapper.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/DCParser.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/LogicParser.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/ParserError.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/RAParser.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/DCOperand.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/LogicElement.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/LogicOperand.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/LogicOperator.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/RABinaryOperator.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/RAElement.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/RAOperand.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/RAOperator.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/RAUnaryOperator.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Add.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/And.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/ArrowLeft.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/ConditionalSet.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Cross.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Equal.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/GreaterThan.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/GreaterThanEqual.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Intersection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Join.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/LeftOuterJoin.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/LessThan.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/LessThanEqual.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Minus.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Multiply.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Or.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/RightOuterJoin.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Unequal.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Union.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/unary/Not.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/unary/Projection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/unary/Rename.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/unary/Selection.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/unary/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/tokenizer/Token.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/tokenizer/Tokenizer.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/tokenizer/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/util/RenamableColumn.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/util/RenamableColumnList.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/util/__init__.py +0 -0
- {jupyter_duckdb-1.2.7/test → jupyter_duckdb-1.2.101/src/duckdb_kernel/tests}/test_result_comparison.py +0 -0
- {jupyter_duckdb-1.2.7/test → jupyter_duckdb-1.2.101/src/duckdb_kernel/tests}/test_sql.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/util/ResultSetComparator.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/util/SQL.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/util/TestError.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/util/__init__.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/util/formatting.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/visualization/Drawer.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/visualization/RATreeDrawer.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/visualization/SchemaDrawer.py +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/jupyter_duckdb.egg-info/dependency_links.txt +0 -0
- {jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/jupyter_duckdb.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jupyter-duckdb
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.101
|
|
4
4
|
Summary: a basic wrapper kernel for DuckDB
|
|
5
5
|
Home-page: https://github.com/erictroebs/jupyter-duckdb
|
|
6
6
|
Author: Eric Tröbs
|
|
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
Requires-Dist: jupyter
|
|
15
15
|
Requires-Dist: graphviz==0.20.3
|
|
16
16
|
Requires-Dist: checkmarkandcross
|
|
17
|
-
Requires-Dist: duckdb==1.2.
|
|
17
|
+
Requires-Dist: duckdb==1.2.1
|
|
18
18
|
Dynamic: author
|
|
19
19
|
Dynamic: author-email
|
|
20
20
|
Dynamic: classifier
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
# configuration
|
|
4
|
+
PACKAGE_VERSION = '1.2.101'
|
|
5
|
+
DUCKDB_VERSION = '1.2.1'
|
|
6
|
+
|
|
7
|
+
DEPENDENCIES = [
|
|
8
|
+
'jupyter',
|
|
9
|
+
'graphviz==0.20.3',
|
|
10
|
+
'checkmarkandcross'
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
if os.getenv('SQLITE') != '1' and os.getenv('DUCKDB') != '0':
|
|
14
|
+
DEPENDENCIES += [f'duckdb=={DUCKDB_VERSION}']
|
|
15
|
+
|
|
16
|
+
# main setup
|
|
17
|
+
if __name__ == '__main__':
|
|
18
|
+
from setuptools import setup, find_namespace_packages
|
|
19
|
+
|
|
20
|
+
# load README.md as long_description
|
|
21
|
+
with open('README.md', 'r', encoding='utf-8') as file:
|
|
22
|
+
long_description = file.read()
|
|
23
|
+
|
|
24
|
+
# main setup call
|
|
25
|
+
setup(
|
|
26
|
+
name='jupyter-duckdb',
|
|
27
|
+
version=PACKAGE_VERSION,
|
|
28
|
+
python_requires='>=3.10',
|
|
29
|
+
install_requires=DEPENDENCIES,
|
|
30
|
+
author='Eric Tröbs',
|
|
31
|
+
author_email='eric.troebs@tu-ilmenau.de',
|
|
32
|
+
description='a basic wrapper kernel for DuckDB',
|
|
33
|
+
long_description=long_description,
|
|
34
|
+
long_description_content_type='text/markdown',
|
|
35
|
+
url='https://github.com/erictroebs/jupyter-duckdb',
|
|
36
|
+
project_urls={
|
|
37
|
+
'Bug Tracker': 'https://github.com/erictroebs/jupyter-duckdb/issues',
|
|
38
|
+
},
|
|
39
|
+
classifiers=[
|
|
40
|
+
'Programming Language :: Python :: 3',
|
|
41
|
+
'License :: OSI Approved :: MIT License',
|
|
42
|
+
'Operating System :: OS Independent',
|
|
43
|
+
],
|
|
44
|
+
package_dir={'': 'src'},
|
|
45
|
+
packages=find_namespace_packages(where='src'),
|
|
46
|
+
include_package_data=True,
|
|
47
|
+
package_data={
|
|
48
|
+
'duckdb_kernel': [
|
|
49
|
+
'kernel.json'
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
@@ -54,6 +54,8 @@ class DuckDBKernel(Kernel):
|
|
|
54
54
|
MagicCommand('all_dc').arg('value', '1').on(self._all_dc_magic),
|
|
55
55
|
MagicCommand('auto_parser').disable('sql', 'ra', 'dc').code(True).on(self._auto_parser_magic),
|
|
56
56
|
MagicCommand('guess_parser').arg('value', '1').on(self._guess_parser_magic),
|
|
57
|
+
MagicCommand('plotly').arg('type').arg('mapping').opt('title').result(True).on(self._plotly_magic),
|
|
58
|
+
MagicCommand('plotly_raw').opt('title').result(True).on(self._plotly_raw_magic)
|
|
57
59
|
)
|
|
58
60
|
|
|
59
61
|
# create placeholders for database and tests
|
|
@@ -577,6 +579,90 @@ class DuckDBKernel(Kernel):
|
|
|
577
579
|
if e.depth > 0:
|
|
578
580
|
raise e
|
|
579
581
|
|
|
582
|
+
def _plotly_magic(self, silent: bool, cols: List, rows: List[Tuple], type: str, mapping: str, title: str = None):
|
|
583
|
+
# split mapping and handle asterisks
|
|
584
|
+
mapping = [m.strip() for m in mapping.split(',')]
|
|
585
|
+
|
|
586
|
+
for i in range(len(mapping)):
|
|
587
|
+
if mapping[i] == '*':
|
|
588
|
+
mapping = mapping[:i] + cols + mapping[i+1:]
|
|
589
|
+
|
|
590
|
+
# convert all column names to lower case
|
|
591
|
+
lower_cols = [c.lower() for c in cols]
|
|
592
|
+
lower_mapping = [m.lower() for m in mapping]
|
|
593
|
+
|
|
594
|
+
# map desired columns to indices
|
|
595
|
+
mapped_indices = {}
|
|
596
|
+
for ok, lk in zip(mapping, lower_mapping):
|
|
597
|
+
for i in range(len(lower_cols)):
|
|
598
|
+
if lk == lower_cols[i]:
|
|
599
|
+
mapped_indices[ok] = i
|
|
600
|
+
break
|
|
601
|
+
else:
|
|
602
|
+
raise ValueError(f'unknown column {ok}')
|
|
603
|
+
|
|
604
|
+
# map desired columns to value lists
|
|
605
|
+
mapped_values = {
|
|
606
|
+
m: [r[i] for r in rows]
|
|
607
|
+
for m, i in mapped_indices.items()
|
|
608
|
+
}
|
|
609
|
+
mapped_keys = iter(mapped_values.keys())
|
|
610
|
+
|
|
611
|
+
# get required chart type
|
|
612
|
+
match type.lower():
|
|
613
|
+
case 'scatter':
|
|
614
|
+
if len(lower_mapping) < 2: raise ValueError('scatter requires at least x and y values')
|
|
615
|
+
html = draw_scatter_chart(title,
|
|
616
|
+
mapped_values[next(mapped_keys)],
|
|
617
|
+
**{k: mapped_values[k] for k in mapped_keys})
|
|
618
|
+
case 'line':
|
|
619
|
+
if len(lower_mapping) < 2: raise ValueError('lines requires at least x and y values')
|
|
620
|
+
html = draw_line_chart(title,
|
|
621
|
+
mapped_values[next(mapped_keys)],
|
|
622
|
+
**{k: mapped_values[k] for k in mapped_keys})
|
|
623
|
+
|
|
624
|
+
case 'bar':
|
|
625
|
+
if len(lower_mapping) < 2: raise ValueError('bar requires at least x and y values')
|
|
626
|
+
html = draw_bar_chart(title,
|
|
627
|
+
mapped_values[next(mapped_keys)],
|
|
628
|
+
**{k: mapped_values[k] for k in mapped_keys})
|
|
629
|
+
|
|
630
|
+
case 'pie':
|
|
631
|
+
if len(lower_mapping) != 2: raise ValueError('pie requires labels and values')
|
|
632
|
+
html = draw_pie_chart(title,
|
|
633
|
+
mapped_values[next(mapped_keys)],
|
|
634
|
+
mapped_values[next(mapped_keys)])
|
|
635
|
+
|
|
636
|
+
case 'bubble':
|
|
637
|
+
if len(lower_mapping) != 4: raise ValueError('bubble requires x, y, size and color')
|
|
638
|
+
html = draw_bubble_chart(title,
|
|
639
|
+
mapped_values[next(mapped_keys)],
|
|
640
|
+
mapped_values[next(mapped_keys)],
|
|
641
|
+
mapped_values[next(mapped_keys)],
|
|
642
|
+
mapped_values[next(mapped_keys)])
|
|
643
|
+
|
|
644
|
+
case 'heatmap':
|
|
645
|
+
if len(lower_mapping) != 3: raise ValueError('heatmap requires x, y and z values')
|
|
646
|
+
html = draw_heatmap_chart(title,
|
|
647
|
+
mapped_values[next(mapped_keys)],
|
|
648
|
+
mapped_values[next(mapped_keys)],
|
|
649
|
+
mapped_values[next(mapped_keys)])
|
|
650
|
+
|
|
651
|
+
case _:
|
|
652
|
+
raise ValueError(f'unknown type: {type}')
|
|
653
|
+
|
|
654
|
+
# finally print the code
|
|
655
|
+
self.print_data(html, mime='text/html')
|
|
656
|
+
|
|
657
|
+
def _plotly_raw_magic(self, silent: bool, cols: List, rows: List[Tuple], title: str = None):
|
|
658
|
+
if len(cols) != 1 and len(rows) != 1:
|
|
659
|
+
raise ValueError(f'expected exactly one column and one row')
|
|
660
|
+
|
|
661
|
+
self.print_data(
|
|
662
|
+
draw_chart(title, rows[0][0]),
|
|
663
|
+
mime='text/html'
|
|
664
|
+
)
|
|
665
|
+
|
|
580
666
|
# jupyter related functions
|
|
581
667
|
def do_execute(self, code: str, silent: bool,
|
|
582
668
|
store_history: bool = True, user_expressions: dict = None, allow_stdin: bool = False,
|
{jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/magics/MagicCommandHandler.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from typing import Dict, Tuple, List
|
|
2
|
+
from typing import Dict, Tuple, List
|
|
3
3
|
|
|
4
4
|
from . import MagicCommand, MagicCommandException, MagicCommandCallback
|
|
5
5
|
from .StringWrapper import StringWrapper
|
|
@@ -62,6 +62,11 @@ class MagicCommandHandler:
|
|
|
62
62
|
args = [group if group is not None else default
|
|
63
63
|
for group, (_, default, _) in zip(match.groups(), magic.args)]
|
|
64
64
|
|
|
65
|
+
args = [arg[1:-1]
|
|
66
|
+
if arg is not None and (arg[0] == '"' and arg[-1] == '"' or arg[0] == "'" and arg[-1] == "'")
|
|
67
|
+
else arg
|
|
68
|
+
for arg in args]
|
|
69
|
+
|
|
65
70
|
if any(arg is None for arg in args):
|
|
66
71
|
raise MagicCommandException(f'could not parse parameters for command "{command}"')
|
|
67
72
|
|
|
@@ -87,6 +92,9 @@ class MagicCommandHandler:
|
|
|
87
92
|
value = match.group(i + 2)
|
|
88
93
|
i += 3
|
|
89
94
|
|
|
95
|
+
if value is not None and (value[0] == '"' and value[-1] == '"' or value[0] == "'" and value[-1] == "'"):
|
|
96
|
+
value = value[1:-1]
|
|
97
|
+
|
|
90
98
|
if name is not None:
|
|
91
99
|
optionals[name.lower()] = value
|
|
92
100
|
|
|
@@ -8,7 +8,7 @@ from ...util.RenamableColumnList import RenamableColumnList
|
|
|
8
8
|
class Difference(RABinaryOperator):
|
|
9
9
|
@staticmethod
|
|
10
10
|
def symbols() -> Tuple[str, ...]:
|
|
11
|
-
return '\\'
|
|
11
|
+
return '-', '\\'
|
|
12
12
|
|
|
13
13
|
def to_sql(self, tables: Dict[str, Table]) -> Tuple[str, RenamableColumnList]:
|
|
14
14
|
# execute subqueries
|
{jupyter_duckdb-1.2.7 → jupyter_duckdb-1.2.101}/src/duckdb_kernel/parser/elements/binary/Division.py
RENAMED
|
@@ -27,10 +27,6 @@ class Division(RABinaryOperator):
|
|
|
27
27
|
# inter_name_left = ', '.join(l.current_name for l, _ in inter_cols)
|
|
28
28
|
inter_name_right = ', '.join(r.current_name for _, r in inter_cols)
|
|
29
29
|
|
|
30
|
-
print('-', diff_name)
|
|
31
|
-
print(inter_name)
|
|
32
|
-
print(inter_name_right)
|
|
33
|
-
|
|
34
30
|
# create sql
|
|
35
31
|
return f'''
|
|
36
32
|
SELECT {diff_name}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
from typing import Optional
|
|
1
2
|
from typing import Tuple, Dict
|
|
2
3
|
|
|
3
4
|
from duckdb_kernel.db import Table
|
|
4
5
|
from ..RABinaryOperator import RABinaryOperator
|
|
6
|
+
from ...util.RenamableColumn import RenamableColumn
|
|
5
7
|
from ...util.RenamableColumnList import RenamableColumnList
|
|
6
8
|
|
|
7
9
|
|
|
@@ -10,6 +12,13 @@ class FullOuterJoin(RABinaryOperator):
|
|
|
10
12
|
def symbols() -> Tuple[str, ...]:
|
|
11
13
|
return chr(10199), 'fjoin', 'ojoin'
|
|
12
14
|
|
|
15
|
+
@staticmethod
|
|
16
|
+
def _coalesce(c1: RenamableColumn, c2: Optional[RenamableColumn]) -> str:
|
|
17
|
+
if c2 is not None:
|
|
18
|
+
return f'COALESCE({c1.current_name}, {c2.current_name}) AS {c1.current_name}'
|
|
19
|
+
else:
|
|
20
|
+
return c1.current_name
|
|
21
|
+
|
|
13
22
|
def to_sql(self, tables: Dict[str, Table]) -> Tuple[str, RenamableColumnList]:
|
|
14
23
|
# execute subqueries
|
|
15
24
|
lq, lcols = self.left.to_sql(tables)
|
|
@@ -19,9 +28,7 @@ class FullOuterJoin(RABinaryOperator):
|
|
|
19
28
|
join_cols, all_cols = lcols.intersect(rcols)
|
|
20
29
|
|
|
21
30
|
replacements = {c1: c2 for c1, c2 in join_cols}
|
|
22
|
-
select_cols = [
|
|
23
|
-
f'COALESCE({c.current_name}, {replacements.get(c).current_name})' if c in replacements else c.current_name
|
|
24
|
-
for c in all_cols]
|
|
31
|
+
select_cols = [self._coalesce(c, replacements.get(c)) for c in all_cols]
|
|
25
32
|
select_clause = ', '.join(select_cols)
|
|
26
33
|
|
|
27
34
|
on_clause = ' AND '.join(f'{l.current_name} = {r.current_name}' for l, r in join_cols)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, List, Tuple
|
|
3
|
+
|
|
4
|
+
from duckdb_kernel.db import Connection as DB, Table
|
|
5
|
+
from duckdb_kernel.db.error import EmptyResultError
|
|
6
|
+
from duckdb_kernel.parser.elements import RAElement
|
|
7
|
+
from duckdb_kernel.parser.elements.binary import ConditionalSet
|
|
8
|
+
|
|
9
|
+
with open('examples/tables.sql', 'r', encoding='utf-8') as file:
|
|
10
|
+
EXAMPLE_STMTS = [stmt
|
|
11
|
+
for stmt in file.read().split(';')
|
|
12
|
+
if stmt.strip()]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Connection:
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
db_type = os.environ.get('DB_TYPE')
|
|
18
|
+
if db_type == 'postgres':
|
|
19
|
+
host = os.environ.get('POSTGRES_HOST', 'localhost')
|
|
20
|
+
port = int(os.environ.get('POSTGRES_PORT', 5432))
|
|
21
|
+
username = os.environ.get('POSTGRES_USER', 'postgres')
|
|
22
|
+
password = os.environ.get('POSTGRES_PASSWORD', 'postgres')
|
|
23
|
+
|
|
24
|
+
from duckdb_kernel.db.implementation.postgres import Connection as PostgreSQL
|
|
25
|
+
self.con: DB = PostgreSQL(host, port, username, password, None)
|
|
26
|
+
elif db_type == 'sqlite':
|
|
27
|
+
from duckdb_kernel.db.implementation.sqlite import Connection as SQLite
|
|
28
|
+
self.con: DB = SQLite(':memory:')
|
|
29
|
+
else:
|
|
30
|
+
from duckdb_kernel.db.implementation.duckdb import Connection as DuckDB
|
|
31
|
+
self.con: DB = DuckDB(':memory:')
|
|
32
|
+
|
|
33
|
+
for stmt in EXAMPLE_STMTS:
|
|
34
|
+
try:
|
|
35
|
+
self.con.execute(stmt)
|
|
36
|
+
except EmptyResultError:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
42
|
+
self.con.close()
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def tables(self) -> Dict[str, Table]:
|
|
46
|
+
return self.con.analyze()
|
|
47
|
+
|
|
48
|
+
def execute_sql_return_cols(self, query: str) -> Tuple[List, List]:
|
|
49
|
+
return self.con.execute(query)
|
|
50
|
+
|
|
51
|
+
def execute_sql(self, query: str) -> List:
|
|
52
|
+
_, rows = self.execute_sql_return_cols(query)
|
|
53
|
+
return rows
|
|
54
|
+
|
|
55
|
+
def execute_ra_return_cols(self, root: RAElement) -> Tuple[List, List]:
|
|
56
|
+
sql = root.to_sql_with_renamed_columns(self.tables)
|
|
57
|
+
cols, rows = self.execute_sql_return_cols(sql)
|
|
58
|
+
|
|
59
|
+
return cols, sorted(rows, key=lambda t: tuple(-1 if x is None else x for x in t))
|
|
60
|
+
|
|
61
|
+
def execute_ra(self, root: RAElement) -> List:
|
|
62
|
+
_, rows = self.execute_ra_return_cols(root)
|
|
63
|
+
return rows
|
|
64
|
+
|
|
65
|
+
def execute_dc_return_cols(self, root: ConditionalSet) -> Tuple[List, List]:
|
|
66
|
+
sql, cnm = root.to_sql_with_renamed_columns(self.tables)
|
|
67
|
+
cols, rows = self.execute_sql_return_cols(sql)
|
|
68
|
+
|
|
69
|
+
return [cnm.get(c, c) for c in cols], sorted(rows)
|
|
70
|
+
|
|
71
|
+
def execute_dc(self, root: ConditionalSet) -> List:
|
|
72
|
+
_, rows = self.execute_dc_return_cols(root)
|
|
73
|
+
return rows
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
__all__ = ['Connection']
|
|
@@ -13,7 +13,12 @@ def test_case_insensitivity():
|
|
|
13
13
|
|
|
14
14
|
# execute to test case insensitivity
|
|
15
15
|
with Connection() as con:
|
|
16
|
-
|
|
16
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
17
|
+
|
|
18
|
+
assert [c.lower() for c in cols] == [
|
|
19
|
+
'username'
|
|
20
|
+
]
|
|
21
|
+
assert rows == [
|
|
17
22
|
('Alice',),
|
|
18
23
|
('Bob',),
|
|
19
24
|
('Charlie',)
|
|
@@ -29,7 +34,12 @@ def test_case_insensitivity():
|
|
|
29
34
|
|
|
30
35
|
# execute to test case insensitivity
|
|
31
36
|
with Connection() as con:
|
|
32
|
-
|
|
37
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
38
|
+
|
|
39
|
+
assert [c.lower() for c in cols] == [
|
|
40
|
+
'username'
|
|
41
|
+
]
|
|
42
|
+
assert rows == [
|
|
33
43
|
('Alice',),
|
|
34
44
|
('Bob',),
|
|
35
45
|
('Charlie',)
|
|
@@ -46,7 +56,12 @@ def test_simple_queries():
|
|
|
46
56
|
'id | Users (id ,_)',
|
|
47
57
|
]:
|
|
48
58
|
root = DCParser.parse_query(query)
|
|
49
|
-
|
|
59
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
60
|
+
|
|
61
|
+
assert [c.lower() for c in cols] == [
|
|
62
|
+
'id'
|
|
63
|
+
]
|
|
64
|
+
assert rows == [
|
|
50
65
|
(1,),
|
|
51
66
|
(2,),
|
|
52
67
|
(3,)
|
|
@@ -57,7 +72,13 @@ def test_simple_queries():
|
|
|
57
72
|
'{ id,name | Users(id, name) }'
|
|
58
73
|
]:
|
|
59
74
|
root = DCParser.parse_query(query)
|
|
60
|
-
|
|
75
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
76
|
+
|
|
77
|
+
assert [c.lower() for c in cols] == [
|
|
78
|
+
'id',
|
|
79
|
+
'name'
|
|
80
|
+
]
|
|
81
|
+
assert rows == [
|
|
61
82
|
(1, 'Alice'),
|
|
62
83
|
(2, 'Bob'),
|
|
63
84
|
(3, 'Charlie')
|
|
@@ -67,14 +88,25 @@ def test_simple_queries():
|
|
|
67
88
|
def test_asterisk_projection():
|
|
68
89
|
with Connection() as con:
|
|
69
90
|
root = DCParser.parse_query('{ * | Users(id, _) }')
|
|
70
|
-
|
|
91
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
92
|
+
|
|
93
|
+
assert [c.lower() for c in cols] == [
|
|
94
|
+
'id'
|
|
95
|
+
]
|
|
96
|
+
assert rows == [
|
|
71
97
|
(1,),
|
|
72
98
|
(2,),
|
|
73
99
|
(3,)
|
|
74
100
|
]
|
|
75
101
|
|
|
76
102
|
root = DCParser.parse_query('{ * | Users(id, name) }')
|
|
77
|
-
|
|
103
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
104
|
+
|
|
105
|
+
assert [c.lower() for c in cols] == [
|
|
106
|
+
'id',
|
|
107
|
+
'name'
|
|
108
|
+
]
|
|
109
|
+
assert rows == [
|
|
78
110
|
(1, 'Alice'),
|
|
79
111
|
(2, 'Bob'),
|
|
80
112
|
(3, 'Charlie')
|
|
@@ -89,7 +121,12 @@ def test_conditions():
|
|
|
89
121
|
'{ name | Users(id, name) ∧ (id = 2 ∨ id = 3) }'
|
|
90
122
|
]:
|
|
91
123
|
root = DCParser.parse_query(query)
|
|
92
|
-
|
|
124
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
125
|
+
|
|
126
|
+
assert [c.lower() for c in cols] == [
|
|
127
|
+
'name'
|
|
128
|
+
]
|
|
129
|
+
assert rows == [
|
|
93
130
|
('Bob',),
|
|
94
131
|
('Charlie',)
|
|
95
132
|
]
|
|
@@ -99,7 +136,12 @@ def test_conditions():
|
|
|
99
136
|
'{ id | Users(id, name) ∧ name > "B" ∧ name < "C" }',
|
|
100
137
|
]:
|
|
101
138
|
root = DCParser.parse_query(query)
|
|
102
|
-
|
|
139
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
140
|
+
|
|
141
|
+
assert [c.lower() for c in cols] == [
|
|
142
|
+
'id'
|
|
143
|
+
]
|
|
144
|
+
assert rows == [
|
|
103
145
|
(2,)
|
|
104
146
|
]
|
|
105
147
|
|
|
@@ -111,7 +153,12 @@ def test_shortcut_conditions():
|
|
|
111
153
|
'{ name | Users(1, name) }'
|
|
112
154
|
]:
|
|
113
155
|
root = DCParser.parse_query(query)
|
|
114
|
-
|
|
156
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
157
|
+
|
|
158
|
+
assert [c.lower() for c in cols] == [
|
|
159
|
+
'name'
|
|
160
|
+
]
|
|
161
|
+
assert rows == [
|
|
115
162
|
('Alice',)
|
|
116
163
|
]
|
|
117
164
|
|
|
@@ -119,7 +166,12 @@ def test_shortcut_conditions():
|
|
|
119
166
|
'{ season_name | Seasons(1, 1, season_name) }'
|
|
120
167
|
]:
|
|
121
168
|
root = DCParser.parse_query(query)
|
|
122
|
-
|
|
169
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
170
|
+
|
|
171
|
+
assert [c.lower() for c in cols] == [
|
|
172
|
+
'season_name'
|
|
173
|
+
]
|
|
174
|
+
assert rows == [
|
|
123
175
|
('Show 1 / Season 1',)
|
|
124
176
|
]
|
|
125
177
|
|
|
@@ -128,7 +180,13 @@ def test_shortcut_conditions():
|
|
|
128
180
|
'{ sname, ename | Seasons(snum, 2, sname) ∧ Episodes(enum, snum, 2, ename) }'
|
|
129
181
|
]:
|
|
130
182
|
root = DCParser.parse_query(query)
|
|
131
|
-
|
|
183
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
184
|
+
|
|
185
|
+
assert [c.lower() for c in cols] == [
|
|
186
|
+
'sname',
|
|
187
|
+
'ename'
|
|
188
|
+
]
|
|
189
|
+
assert rows == [
|
|
132
190
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 1'),
|
|
133
191
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 2'),
|
|
134
192
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 3'),
|
|
@@ -146,7 +204,12 @@ def test_joins():
|
|
|
146
204
|
'{ sename | Shows(shid, shname) ∧ Seasons(senum, shid, sename) }'
|
|
147
205
|
]:
|
|
148
206
|
root = DCParser.parse_query(query)
|
|
149
|
-
|
|
207
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
208
|
+
|
|
209
|
+
assert [c.lower() for c in cols] == [
|
|
210
|
+
'sename'
|
|
211
|
+
]
|
|
212
|
+
assert rows == [
|
|
150
213
|
('Show 1 / Season 1',),
|
|
151
214
|
('Show 1 / Season 2',),
|
|
152
215
|
('Show 2 / Season 1',),
|
|
@@ -158,7 +221,12 @@ def test_joins():
|
|
|
158
221
|
'{ sename | Seasons(senum, shid, sename) ∧ Shows(shid, "Show 1") }'
|
|
159
222
|
]:
|
|
160
223
|
root = DCParser.parse_query(query)
|
|
161
|
-
|
|
224
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
225
|
+
|
|
226
|
+
assert [c.lower() for c in cols] == [
|
|
227
|
+
'sename'
|
|
228
|
+
]
|
|
229
|
+
assert rows == [
|
|
162
230
|
('Show 1 / Season 1',),
|
|
163
231
|
('Show 1 / Season 2',)
|
|
164
232
|
]
|
|
@@ -168,7 +236,13 @@ def test_joins():
|
|
|
168
236
|
'{ sname, ename | Seasons(snum, shid, sname) ∧ Episodes(enum, snum, shid, ename) ∧ shid = 2 }'
|
|
169
237
|
]:
|
|
170
238
|
root = DCParser.parse_query(query)
|
|
171
|
-
|
|
239
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
240
|
+
|
|
241
|
+
assert [c.lower() for c in cols] == [
|
|
242
|
+
'sname',
|
|
243
|
+
'ename'
|
|
244
|
+
]
|
|
245
|
+
assert rows == [
|
|
172
246
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 1'),
|
|
173
247
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 2'),
|
|
174
248
|
('Show 2 / Season 1', 'Show 2 / Season 1 / Episode 3'),
|
|
@@ -183,13 +257,24 @@ def test_joins():
|
|
|
183
257
|
'{ s2,c5 | Shows(s1,s2) ∧ Episodes(e1,e2,s1,e4) ∧ Characters(c1,e1,c3,s1,c5) ∧ s1=2 ∧ e4="Show 2 / Season 1 / Episode 2" }'
|
|
184
258
|
]:
|
|
185
259
|
root = DCParser.parse_query(query)
|
|
186
|
-
|
|
260
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
261
|
+
|
|
262
|
+
assert [c.lower() for c in cols] == [
|
|
263
|
+
's2',
|
|
264
|
+
'c5'
|
|
265
|
+
]
|
|
266
|
+
assert rows == [
|
|
187
267
|
('Show 2', 'Actor F')
|
|
188
268
|
]
|
|
189
269
|
|
|
190
270
|
# cross join
|
|
191
271
|
root = DCParser.parse_query('{ sename | Shows(shid1, shname) ∧ Seasons(senum, shid2, sename) ∧ shid1 = shid2 }')
|
|
192
|
-
|
|
272
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
273
|
+
|
|
274
|
+
assert [c.lower() for c in cols] == [
|
|
275
|
+
'sename'
|
|
276
|
+
]
|
|
277
|
+
assert rows == [
|
|
193
278
|
('Show 1 / Season 1',),
|
|
194
279
|
('Show 1 / Season 2',),
|
|
195
280
|
('Show 2 / Season 1',),
|
|
@@ -201,7 +286,13 @@ def test_joins():
|
|
|
201
286
|
'{ s2,c5 | Shows(sa1,s2) ∧ Episodes(e1,e2,sb1,e4) ∧ Characters(c1,e1,c3,sc1,c5) ∧ sa1=2 ∧ sa1 = sb1 ∧ sb1 = sc1 ∧ e4="Show 2 / Season 1 / Episode 2" }'
|
|
202
287
|
]:
|
|
203
288
|
root = DCParser.parse_query(query)
|
|
204
|
-
|
|
289
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
290
|
+
|
|
291
|
+
assert [c.lower() for c in cols] == [
|
|
292
|
+
's2',
|
|
293
|
+
'c5'
|
|
294
|
+
]
|
|
295
|
+
assert rows == [
|
|
205
296
|
('Show 2', 'Actor F')
|
|
206
297
|
]
|
|
207
298
|
|
|
@@ -213,7 +304,14 @@ def test_disjunction_joins():
|
|
|
213
304
|
"{ enum, snum, sid | Episodes(enum, snum, sid, ename) ∧ (Characters(cname1, enum, snum, sid, _) ∧ cname1 = 'Character B' ∨ Characters(cname2, enum, snum, sid, _) ∧ cname2 = 'Character D') }",
|
|
214
305
|
]:
|
|
215
306
|
root = DCParser.parse_query(query)
|
|
216
|
-
|
|
307
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
308
|
+
|
|
309
|
+
assert [c.lower() for c in cols] == [
|
|
310
|
+
'enum',
|
|
311
|
+
'snum',
|
|
312
|
+
'sid'
|
|
313
|
+
]
|
|
314
|
+
assert rows == [
|
|
217
315
|
(1, 1, 1),
|
|
218
316
|
(2, 1, 1)
|
|
219
317
|
]
|
|
@@ -225,7 +323,13 @@ def test_cross_join():
|
|
|
225
323
|
"{ cname1, cname2 | Characters(cname1, _, _, 2, _) ∧ Characters(cname2, _, _, 2, _) }",
|
|
226
324
|
]:
|
|
227
325
|
root = DCParser.parse_query(query)
|
|
228
|
-
|
|
326
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
327
|
+
|
|
328
|
+
assert [c.lower() for c in cols] == [
|
|
329
|
+
'cname1',
|
|
330
|
+
'cname2'
|
|
331
|
+
]
|
|
332
|
+
assert rows == [
|
|
229
333
|
('Character E', 'Character E'),
|
|
230
334
|
('Character E', 'Character F'),
|
|
231
335
|
('Character F', 'Character E'),
|
|
@@ -243,7 +347,12 @@ def test_underscores():
|
|
|
243
347
|
'{ ename | Seasons(snum, shid, sname) ∧ Episodes(_, __, shid, ename) ∧ shid = 2 }'
|
|
244
348
|
]:
|
|
245
349
|
root = DCParser.parse_query(query)
|
|
246
|
-
|
|
350
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
351
|
+
|
|
352
|
+
assert [c.lower() for c in cols] == [
|
|
353
|
+
'ename'
|
|
354
|
+
]
|
|
355
|
+
assert rows == [
|
|
247
356
|
('Show 2 / Season 1 / Episode 1',),
|
|
248
357
|
('Show 2 / Season 1 / Episode 2',),
|
|
249
358
|
('Show 2 / Season 1 / Episode 3',),
|
|
@@ -258,7 +367,12 @@ def test_underscores():
|
|
|
258
367
|
'{ ename | Seasons(snum, shid, sname) ∧ Episodes(_, _, shid, ename) ∧ shid = 2 }'
|
|
259
368
|
]:
|
|
260
369
|
root = DCParser.parse_query(query)
|
|
261
|
-
|
|
370
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
371
|
+
|
|
372
|
+
assert [c.lower() for c in cols] == [
|
|
373
|
+
'ename'
|
|
374
|
+
]
|
|
375
|
+
assert rows == [
|
|
262
376
|
('Show 2 / Season 1 / Episode 1',),
|
|
263
377
|
('Show 2 / Season 1 / Episode 2',),
|
|
264
378
|
('Show 2 / Season 1 / Episode 3',),
|
|
@@ -274,7 +388,12 @@ def test_underscores():
|
|
|
274
388
|
'{ ename | Seasons(_, shid, __) ∧ Episodes(_, __, shid, ename) ∧ shid = 2 }'
|
|
275
389
|
]:
|
|
276
390
|
root = DCParser.parse_query(query)
|
|
277
|
-
|
|
391
|
+
cols, rows = con.execute_dc_return_cols(root)
|
|
392
|
+
|
|
393
|
+
assert [c.lower() for c in cols] == [
|
|
394
|
+
'ename'
|
|
395
|
+
]
|
|
396
|
+
assert rows == [
|
|
278
397
|
('Show 2 / Season 1 / Episode 1',),
|
|
279
398
|
('Show 2 / Season 1 / Episode 2',),
|
|
280
399
|
('Show 2 / Season 1 / Episode 3',),
|