Skip to content

Conversation

@zfj1
Copy link

@zfj1 zfj1 commented Jan 12, 2023

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:

  • added a new class dj.U which supports restriction by, joining on, and aggregation on a relvar
  • added a switch case in dj.internal.GeneralRelvar.compile which handles dj.U
  • added a protected method in dj.internal.Header which handles updating the primary key
  • added a distinct field to dj.internal.Header similar to the python implementation in order to compile the sql properly
  • added a number of tests

To summarize the changes for the union operator:

  • added assertions as described in the wiki
  • implemented the union logic as laid out in the python implementation.
  • added a protected method to dj.internal.Header to ensure that unioned keys are compiled in the same order, as required by MySQL
  • added a number of tests

@zfj1 zfj1 marked this pull request as ready for review January 12, 2023 20:15
@dimitri-yatsenko
Copy link
Member

Impressive work @zfj1! Let us review and test for a bit.

@A-Baji
Copy link
Collaborator

A-Baji commented Jan 25, 2023

Hello @zfj1. I'm going to go ahead and merge this PR to stage, and then open up a new PR, #421 , from stage to master . That PR will be where your code is reviewed and changes may be requested. This process needs to be done to protect our matlab licenses.

@A-Baji A-Baji merged commit 208c789 into datajoint:stage Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants