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

[Hail][Feature] Add product option to index methods #5937

Merged
merged 9 commits into from May 6, 2019

Conversation

@patrick-schultz
Copy link
Collaborator

@patrick-schultz patrick-schultz commented Apr 22, 2019

Add product option to Table.index, and MatrixTable.{index_rows, index_cols}. Supports interval joins. Refactored the index methods to reduce code duplication, and make them more consistent with each other. Only case not supporting product=True is annotating columns of a matrix table with an interval keyed table.

@patrick-schultz patrick-schultz changed the title [Hail][Feature] Add product option to Table.index [Hail][Feature] Add product option to index methods Apr 23, 2019
Copy link
Collaborator

@tpoterba tpoterba left a comment

looks great, a few minor changes


def _compute_type(self):
child_typ = self.child.typ
if self.product:
Copy link
Collaborator

@tpoterba tpoterba Apr 24, 2019

prefer the if/else to just compute the value type, without duplication of the rest

@@ -2726,6 +2726,8 @@ def index_rows(self, *exprs) -> 'StructExpression':
----------
exprs : variable-length args of :class:`.Expression`
Index expressions.
product : bool
If ``True``, value of expression is array of all matches.
Copy link
Collaborator

@tpoterba tpoterba Apr 24, 2019

Should we mark as experimental? Might want to change the name -- product seems like not quite the right word to communicate the concept.

Copy link
Collaborator Author

@patrick-schultz patrick-schultz Apr 24, 2019

I agree product is a bad name. What about all_matches or collect_matches?

Copy link
Collaborator

@tpoterba tpoterba Apr 24, 2019

Konrad?

Copy link
Collaborator

@konradjk konradjk Apr 24, 2019

Maybe the simpler array=True?

Copy link
Collaborator

@konradjk konradjk Apr 24, 2019

Hmm, this only happens on intervals, right? Yeah, I like something that gets across all

Copy link
Collaborator Author

@patrick-schultz patrick-schultz Apr 24, 2019

Not just intervals. It also makes arrays of all rows with the matching key in the non-interval case.

right = right.select(i=hl.range(right.idx + 1, 5)).explode('i').key_by('i')
left = left.annotate_rows(matches=right.index(left.row_key, product=True))
rows = left.rows()
self.assertTrue(rows.all(rows.matches.length() == rows.row_idx))
Copy link
Collaborator

@tpoterba tpoterba Apr 24, 2019

Can we add a test case here and in test_table.py that tests the content of the joined array, not just the length? Something like annotating the interval as a value (or adding the interval key to the annotated value in all cases) and checking that

@patrick-schultz patrick-schultz dismissed tpoterba’s stale review Apr 25, 2019

addressed comments

@@ -1504,8 +1504,8 @@ def index(self, *exprs, product=False) -> 'Expression':
----------
exprs : variable-length args of :class:`.Expression`
Index expressions.
product : bool
If ``True``, value of expression is array of all matches.
all_matches : bool
Copy link
Collaborator

@konradjk konradjk Apr 25, 2019

You renamed it to all_matches, but in the downstream code it's still product

@tpoterba tpoterba dismissed their stale review Apr 25, 2019

oh yeah, name needs to be consistent

Copy link
Collaborator

@tpoterba tpoterba left a comment

er, meant to request changes. need to fix names

@marksantcroos
Copy link
Contributor

@marksantcroos marksantcroos commented May 3, 2019

Just letting know that this PR also addresses my issue in https://discuss.hail.is/t/annotate-matrixtable-with-count-from-another-table/950.

@danking danking merged commit a4f829b into hail-is:master May 6, 2019
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants