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

HIVE-28050: Disable Incremental non aggregated materialized view rebuild in presence of delete operations #5053

Merged
merged 3 commits into from Feb 12, 2024

Conversation

kasakrisz
Copy link
Contributor

@kasakrisz kasakrisz commented Jan 31, 2024

What changes were proposed in this pull request?

Remove code of incremental rebuild of materialized views without aggregate in presence of delete operations

Why are the changes needed?

The current implementations leads to data correctness issues when a source table does not have a unique column.

Does this PR introduce any user-facing change?

No.

Is the change a dependency upgrade?

No.

How was this patch tested?

mvn test -Dtest.output.overwrite -DskipSparkTests -Dtest=TestMiniLlapLocalCliDriver -Dqfile=materialized_view_create_rewrite_5.q,materialized_view_create_rewrite_8.q,materialized_view_create_rewrite_12.q -pl itests/qtest -Pitests

@@ -480,8 +460,6 @@ protected ASTNode fixUpAfterCbo(ASTNode originalAst, ASTNode newAst, CalcitePlan
fixUpASTAggregateInsertDeleteIncrementalRebuild(fixedAST, getMaterializedViewASTBuilder());
return fixedAST;
case JOIN_INSERT_DELETE_REBUILD:
fixUpASTJoinInsertDeleteIncrementalRebuild(fixedAST, getMaterializedViewASTBuilder());
return fixedAST;

Choose a reason for hiding this comment

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

This will end up throwing the UnsupportedOperationException. Don't we want to fall back to the full rebuild ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point CBO plan is already transformed to AST hence we can not fall back. However JOIN_INSERT_DELETE_REBUILD is never set in the code any more.

Choose a reason for hiding this comment

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

Ok, just for my reference, for the non-groupby queries that this patch is addressing, could you point to where the fall back to the full rebuild (using insert-overwrite) happens ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since JOIN_INSERT_DELETE_REBUILD is not used anymore why not remove it altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -322,8 +318,7 @@ private RelNode applyRecordIncrementalRebuildPlan(
}
return applyAggregateInsertDeleteIncremental(basePlan, mdProvider, executorProvider);
} else {
return applyJoinInsertDeleteIncremental(
basePlan, mdProvider, executorProvider, optCluster, calcitePreMVRewritingPlan);
return calcitePreMVRewritingPlan;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amansinha100
This is the point where we fall back to full rebuild.

Copy link

@amansinha100 amansinha100 left a comment

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

@zabetak zabetak left a comment

Choose a reason for hiding this comment

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

LGTM, left few minor comments but feel free to disregard at your discretion.

@@ -480,8 +460,6 @@ protected ASTNode fixUpAfterCbo(ASTNode originalAst, ASTNode newAst, CalcitePlan
fixUpASTAggregateInsertDeleteIncrementalRebuild(fixedAST, getMaterializedViewASTBuilder());
return fixedAST;
case JOIN_INSERT_DELETE_REBUILD:
fixUpASTJoinInsertDeleteIncrementalRebuild(fixedAST, getMaterializedViewASTBuilder());
return fixedAST;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since JOIN_INSERT_DELETE_REBUILD is not used anymore why not remove it altogether?

Comment on lines +14 to +15
(1, 'alfred', 10.30, 2),
(1, 'alfred', 10.30, 2),
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of modifying existing tests to add duplicates in order to trigger the problem I think it would be better to add a new minimal test like the one you posted last under the JIRA ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the 2nd example from the jira as a new q test but I also kept the change of this one because we ususally face extra challenges in case of MVs with Join.

Copy link

sonarcloud bot commented Feb 12, 2024

Quality Gate Passed Quality Gate passed

Issues
8 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@kasakrisz kasakrisz merged commit 7bff622 into apache:master Feb 12, 2024
6 checks passed
@kasakrisz kasakrisz deleted the HIVE-28050-master-disable-mv-inc branch February 12, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants