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

Fix some bugs in union resolution #3583

Merged
merged 4 commits into from
Jul 11, 2020

Conversation

umanwizard
Copy link
Contributor

@umanwizard umanwizard commented Jul 11, 2020

First bug (reader.rs lines 559-576): In Union-Union resolution, we filter out non-matching unions schemas, instead of writing "None" into the permutation.

This is probably just because I was trying to be too clever and write everything in terms of hard-to-understand iterator chaining, and a "flat_map" crept in there that doesn't semantically make sense. In this PR we replace the complicated and wrong code with simpler and correct code

Second bug (reader.rs line 753): If resolution of any branch of a union fails, we return early from this function, but the error is caught and handled above (to allow other branches to possibly succeed). Thus, before returning, we need to put the resolver back into a consistent state.


This change is Reviewable

@@ -556,24 +556,21 @@ impl<'a> SchemaResolver<'a> {
SchemaPieceRefOrNamed::Piece(SchemaPiece::Union(w_inner)),
SchemaPieceRefOrNamed::Piece(SchemaPiece::Union(r_inner)),
) => {
// TODO (brennan) - can we avoid cloning this?
let w2r = self.writer_to_reader_names.clone();
let permutation = w_inner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this permutation is described in the comment above, but possibly having a simple comment like // Some(val) iff piece is resolvable in both reader and writer, else None would help me understand this logic.

Comment on lines 753 to 754
// This could have just been a "?", except that we need to clean up
// the placeholder values that were added above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

micronit TIOLI: this could just be // clean the placeholder values that were added above

@umanwizard umanwizard merged commit f6a6f54 into MaterializeInc:master Jul 11, 2020
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.

2 participants