Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #930 union join bug, Add test for union join. #967

Merged
merged 4 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967

### 0.13.2 -- May 7, 2021
* Update `setuptools_certificate` dependency to new name `otumat`
Expand Down
6 changes: 4 additions & 2 deletions datajoint/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,11 @@ def join(self, other, semantic_check=True, left=False):
- join_attributes)
# need subquery if any of the join attributes are derived
need_subquery1 = (need_subquery1 or isinstance(self, Aggregation) or
any(n in self.heading.new_attributes for n in join_attributes))
any(n in self.heading.new_attributes for n in join_attributes)
or isinstance(self, Union))
need_subquery2 = (need_subquery2 or isinstance(other, Aggregation) or
any(n in other.heading.new_attributes for n in join_attributes))
any(n in other.heading.new_attributes for n in join_attributes)
or isinstance(self, Union))
if need_subquery1:
self = self.make_subquery()
if need_subquery2:
Expand Down
1 change: 1 addition & 0 deletions docs-parts/intro/Releases_lang1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967

0.13.2 -- May 7, 2021
----------------------
Expand Down
23 changes: 23 additions & 0 deletions tests/test_aggr_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ class X(dj.Lookup):
"""
contents = zip(range(10))

@schema
class TableA(dj.Manual):
definition = """
table_a: int
"""


@schema
class TableB(dj.Manual):
definition = """
-> TableA
table_b: int
"""

jverswijver marked this conversation as resolved.
Show resolved Hide resolved

def test_issue558_part1():
q = (A-B).proj(id2='3')
Expand All @@ -103,3 +117,12 @@ def test_issue558_part2():
d = dict(id=3, id2=5)
assert_equal(len(X & d), len((X & d).proj(id2='3')))


def test_union_join():
# https://github.com/datajoint/datajoint-python/issues/930
TableA.insert(zip([1, 2, 3, 4, 5, 6]))
TableB.insert([(1, 11), (2, 22), (3, 33), (4, 44)])
q1 = TableB & 'table_a < 3'
q2 = TableB & 'table_a > 3'

(q1 + q2) * TableA