Skip to content

Commit 8d97d59

Browse files
committed
stack selects
fix select pass-through issue add tests
1 parent 505e9b1 commit 8d97d59

File tree

6 files changed

+52
-22
lines changed

6 files changed

+52
-22
lines changed

build/lib/data_algebra/data_ops.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,8 @@ def __init__(self, source, columns):
879879
unknown = set(column_selection) - set(source.column_names)
880880
if len(unknown) > 0:
881881
raise ValueError("selecting unknown columns " + str(unknown))
882+
if isinstance(source, SelectColumnsNode):
883+
source = source.sources[0]
882884
ViewRepresentation.__init__(
883885
self, column_names=column_selection, sources=[source]
884886
)

coverage.txt

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22
platform darwin -- Python 3.6.9, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
33
rootdir: /Users/johnmount/Documents/work/data_algebra
44
plugins: cov-2.7.1
5-
collected 30 items
5+
collected 31 items
66

77
tests/test_R_yaml.py . [ 3%]
88
tests/test_apply.py . [ 6%]
9-
tests/test_cdata1.py . [ 10%]
10-
tests/test_cdata_example.py .... [ 23%]
11-
tests/test_cols_used.py . [ 26%]
12-
tests/test_dask.py .. [ 33%]
13-
tests/test_datatable.py . [ 36%]
14-
tests/test_drop_columns.py . [ 40%]
15-
tests/test_example_data_ops.py . [ 43%]
16-
tests/test_exp.py . [ 46%]
17-
tests/test_export_neg.py . [ 50%]
18-
tests/test_free_expr.py . [ 53%]
19-
tests/test_if_else.py . [ 56%]
20-
tests/test_natural_join.py . [ 60%]
21-
tests/test_neg.py . [ 63%]
22-
tests/test_null_bad.py . [ 66%]
23-
tests/test_parse.py . [ 70%]
24-
tests/test_poject.py . [ 73%]
25-
tests/test_scatter_example.py . [ 76%]
26-
tests/test_scoring_example.py . [ 80%]
9+
tests/test_cdata1.py . [ 9%]
10+
tests/test_cdata_example.py .... [ 22%]
11+
tests/test_cols_used.py . [ 25%]
12+
tests/test_dask.py .. [ 32%]
13+
tests/test_datatable.py . [ 35%]
14+
tests/test_drop_columns.py . [ 38%]
15+
tests/test_example_data_ops.py . [ 41%]
16+
tests/test_exp.py . [ 45%]
17+
tests/test_export_neg.py . [ 48%]
18+
tests/test_free_expr.py . [ 51%]
19+
tests/test_if_else.py . [ 54%]
20+
tests/test_natural_join.py . [ 58%]
21+
tests/test_neg.py . [ 61%]
22+
tests/test_null_bad.py . [ 64%]
23+
tests/test_parse.py . [ 67%]
24+
tests/test_poject.py . [ 70%]
25+
tests/test_scatter_example.py . [ 74%]
26+
tests/test_scoring_example.py . [ 77%]
27+
tests/test_select_stacking.py . [ 80%]
2728
tests/test_simple.py ..... [ 96%]
2829
tests/test_sqlite.py . [100%]
2930

@@ -38,7 +39,7 @@ data_algebra/cdata.py 103 20 81%
3839
data_algebra/cdata_impl.py 152 60 61%
3940
data_algebra/dask_model.py 121 23 81%
4041
data_algebra/data_model.py 41 15 63%
41-
data_algebra/data_ops.py 813 173 79%
42+
data_algebra/data_ops.py 815 173 79%
4243
data_algebra/data_pipe.py 183 41 78%
4344
data_algebra/data_types.py 39 19 51%
4445
data_algebra/datatable_model.py 131 81 38%
@@ -53,7 +54,7 @@ data_algebra/pipe.py 65 19 71%
5354
data_algebra/util.py 84 7 92%
5455
data_algebra/yaml.py 120 15 88%
5556
-----------------------------------------------------
56-
TOTAL 2943 802 73%
57+
TOTAL 2945 802 73%
5758

5859

59-
========================== 30 passed in 8.10 seconds ===========================
60+
========================== 31 passed in 7.62 seconds ===========================

data_algebra/data_ops.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,8 @@ def __init__(self, source, columns):
879879
unknown = set(column_selection) - set(source.column_names)
880880
if len(unknown) > 0:
881881
raise ValueError("selecting unknown columns " + str(unknown))
882+
if isinstance(source, SelectColumnsNode):
883+
source = source.sources[0]
882884
ViewRepresentation.__init__(
883885
self, column_names=column_selection, sources=[source]
884886
)
24 Bytes
Binary file not shown.

dist/data_algebra-0.2.2.tar.gz

24 Bytes
Binary file not shown.

tests/test_select_stacking.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
from data_algebra.data_ops import *
3+
4+
5+
def test_select_stacking():
6+
ops1 = TableDescription(
7+
"d", ["a", "b", "c"]
8+
).select_columns(
9+
['a', 'b']
10+
).select_columns(
11+
['a', 'b']
12+
)
13+
ops1_str = format(ops1)
14+
assert ops1_str.count("select_columns")==1
15+
16+
ops2 = TableDescription(
17+
"d", ["a", "b", "c"]
18+
).select_columns(
19+
['a', 'b']
20+
).select_columns(
21+
['a']
22+
)
23+
ops2_str = format(ops2)
24+
assert ops2_str.count("select_columns") == 1
25+

0 commit comments

Comments
 (0)