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

Projects
None yet
5 participants
@patrick-schultz
Copy link
Collaborator

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

@tpoterba
Copy link
Collaborator

left a comment

looks great, a few minor changes


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

This comment has been minimized.

Copy link
@tpoterba

tpoterba Apr 24, 2019

Collaborator

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.

This comment has been minimized.

Copy link
@tpoterba

tpoterba Apr 24, 2019

Collaborator

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

This comment has been minimized.

Copy link
@patrick-schultz

patrick-schultz Apr 24, 2019

Author Collaborator

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

This comment has been minimized.

Copy link
@tpoterba

tpoterba Apr 24, 2019

Collaborator

Konrad?

This comment has been minimized.

Copy link
@konradjk

konradjk Apr 24, 2019

Collaborator

Maybe the simpler array=True?

This comment has been minimized.

Copy link
@konradjk

konradjk Apr 24, 2019

Collaborator

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

This comment has been minimized.

Copy link
@patrick-schultz

patrick-schultz Apr 24, 2019

Author Collaborator

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))

This comment has been minimized.

Copy link
@tpoterba

tpoterba Apr 24, 2019

Collaborator

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

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

This comment has been minimized.

Copy link
@konradjk

konradjk Apr 25, 2019

Collaborator

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

oh yeah, name needs to be consistent

@tpoterba
Copy link
Collaborator

left a comment

er, meant to request changes. need to fix names

@patrick-schultz patrick-schultz force-pushed the patrick-schultz:product_joins branch from 719a960 to 317b4ba May 3, 2019

@marksantcroos

This comment has been minimized.

Copy link
Contributor

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.

@patrick-schultz patrick-schultz force-pushed the patrick-schultz:product_joins branch from 6511bb1 to 5e2c0bb May 6, 2019

@danking danking merged commit a4f829b into hail-is:master May 6, 2019

1 check passed

ci-test success
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.