Conversation
stage <- master
Add support for universal sets and unions
A-Baji
commented
Jan 30, 2023
Comment on lines
7
to
+9
| info % table info | ||
| attributes % array of attributes | ||
| distinct=false% whether to select all the elements or only distinct ones |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| info % table info | |
| attributes % array of attributes | |
| distinct=false% whether to select all the elements or only distinct ones | |
| info % table info | |
| attributes % array of attributes | |
| distinct=false % whether to select all the elements or only distinct ones |
|
|
||
| % promote the keys | ||
| for iAttr = 1:numel(varargin) | ||
| %renamed attribute |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| %renamed attribute | |
| % renamed attribute |
| if ~isempty(toks) | ||
| name = toks{1}{2}; | ||
| else | ||
| %computed attribute |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| %computed attribute | |
| % computed attribute |
| if ~isempty(toks) | ||
| name = toks{1}{2}; | ||
| else | ||
| %regular attribute |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| %regular attribute | |
| % regular attribute |
| assert(isa(arg, 'dj.internal.GeneralRelvar'),... | ||
| 'restriction requires a relvar as operand'); | ||
|
|
||
| % self = init(dj.internal.GeneralRelvar, 'U', {self, arg, 0}); |
Collaborator
Author
There was a problem hiding this comment.
Please remove all instances commented code
Suggested change
| % self = init(dj.internal.GeneralRelvar, 'U', {self, arg, 0}); |
|
|
||
|
|
||
| % Unions may only share primary, but not secondary, keys | ||
| testCase.verifyError(@() count(University.Student() | University.Student()), 'DataJoint:invalidUnion'); |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| testCase.verifyError(@() count(University.Student() | University.Student()), 'DataJoint:invalidUnion'); | |
| testCase.verifyError(@() count(University.Student() + University.Student()), 'DataJoint:invalidUnion'); |
Switch | to +. We are aware that using the + operator raises a warning suggesting to use | instead. This is was due to a convention that no longer applies. We are working on officially switching to +.
| % Unions may only share primary, but not secondary, keys | ||
| testCase.verifyError(@() count(University.Student() | University.Student()), 'DataJoint:invalidUnion'); | ||
| % The primary key of each relation must be the same | ||
| testCase.verifyError(@() count(University.A() | University.Student()), 'DataJoint:invalidUnion'); |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| testCase.verifyError(@() count(University.A() | University.Student()), 'DataJoint:invalidUnion'); | |
| testCase.verifyError(@() count(University.A() + University.Student()), 'DataJoint:invalidUnion'); |
|
|
||
| % A basic union | ||
| testCase.verifyEqual(count(... | ||
| proj(University.Student() & 'student_id<2') | proj(University.Student() & 'student_id>3')),... |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| proj(University.Student() & 'student_id<2') | proj(University.Student() & 'student_id>3')),... | |
| proj(University.Student() & 'student_id<2') + proj(University.Student() & 'student_id>3')),... |
|
|
||
| % Unions with overlapping primary keys are merged | ||
| testCase.verifyEqual(count(... | ||
| proj(University.Student() & 'student_id<3') | proj(University.Student() & 'student_id>1 AND student_id<4')),... |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| proj(University.Student() & 'student_id<3') | proj(University.Student() & 'student_id>1 AND student_id<4')),... | |
| proj(University.Student() & 'student_id<3') + proj(University.Student() & 'student_id>1 AND student_id<4')),... |
| % Unions with disjoint secondary keys are also merged and filled with NULL | ||
| a = University.Student & 'student_id<4'; | ||
| b = proj(University.Student() & 'student_id>1','"test_val"->test_col'); | ||
| c = fetch(a | b, '*'); |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| c = fetch(a | b, '*'); | |
| c = fetch(a + b, '*'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#419