Add support for universal sets and unions #419
Merged
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.
This pull request addresses #89 and #144, adding two important features from the python implementation to MATLAB. I chose to implement these together because the universal set semantics make working with unions much easier. Specifically, since unions may not share any non-key attributes, the universal set allows promotion of non-key attributes to the primary key where appropriate.
Where possible, I've tried to mimic the python implementation. One exception is that as implemented here the universal sets support projection semantics (e.g.,
dj.U('old_key->new_key')). I'm not sure if the python version supports this, since I don't currently have the python distribution set up, though this feature could be removed if desired.To summarize the changes for
dj.U:dj.Uwhich supports restriction by, joining on, and aggregation on a relvardj.internal.GeneralRelvar.compilewhich handlesdj.Udj.internal.Headerwhich handles updating the primary keydistinctfield todj.internal.Headersimilar to the python implementation in order to compile the sql properlyTo summarize the changes for the union operator:
dj.internal.Headerto ensure that unioned keys are compiled in the same order, as required by MySQL