chore: Check materialized view metrics emitted in tests#27724
chore: Check materialized view metrics emitted in tests#27724Sullivan-Patrick wants to merge 1 commit into
Conversation
Reviewer's GuideAdds a reusable test helper that asserts materialized-view rewrites occurred by checking the OPTIMIZED_WITH_MATERIALIZED_VIEW_SUBQUERY_COUNT runtime metric, migrates existing materialized-view planner tests to use it, adds a new metric-focused test, and performs minor test cleanups/renames and formatting adjustments. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
assertMaterializedViewRewriteOccurred, consider including the executed SQL in the assertion failure messages (in addition to the query id) to make it easier to debug why a materialized view rewrite was not detected. - The helper
assertMaterializedViewRewriteOccurredlooks generally useful beyond this class; consider moving it to a shared base test utility so other materialized view tests can assert on the same runtime metric consistently. - The renamed test
testMaterializedViewOptimizationWithUnsupportedFunctionSubquerystill contains a comment stating thatlength()is now supported as a scalar function and both subqueries should be rewritten, which seems inconsistent with the new method name—clarify whether this test is meant to verify support or lack of support and align the name/comment accordingly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `assertMaterializedViewRewriteOccurred`, consider including the executed SQL in the assertion failure messages (in addition to the query id) to make it easier to debug why a materialized view rewrite was not detected.
- The helper `assertMaterializedViewRewriteOccurred` looks generally useful beyond this class; consider moving it to a shared base test utility so other materialized view tests can assert on the same runtime metric consistently.
- The renamed test `testMaterializedViewOptimizationWithUnsupportedFunctionSubquery` still contains a comment stating that `length()` is now supported as a scalar function and both subqueries should be rewritten, which seems inconsistent with the new method name—clarify whether this test is meant to verify support or lack of support and align the name/comment accordingly.
## Individual Comments
### Comment 1
<location path="presto-hive/src/test/java/com/facebook/presto/hive/TestHiveMaterializedViewLogicalPlanner.java" line_range="2130-2131" />
<code_context>
@Test
- public void testMaterializedViewOptimizationWithScalarFunctionSubquery()
+ public void testMaterializedViewOptimizationWithUnsupportedFunctionSubquery()
{
Session queryOptimizationWithMaterializedView = Session.builder(getSession())
</code_context>
<issue_to_address>
**suggestion (testing):** Clarify test intent regarding "unsupported" vs "supported" function rewrites and consider adding a negative case for truly unsupported functions
The renamed test still asserts that rewrites occur for the `length()` subqueries, so it effectively covers a *supported* function scenario. If you want to keep the new name, please also add a separate test using a truly unsupported function that asserts no rewrite (and no metric increment). Otherwise, consider reverting/adjusting the name to reflect that this test covers supported-function rewrites.
```suggestion
@Test
public void testMaterializedViewOptimizationWithSupportedFunctionSubquery()
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @Test | ||
| public void testMaterializedViewOptimizationWithScalarFunctionSubquery() | ||
| public void testMaterializedViewOptimizationWithUnsupportedFunctionSubquery() |
There was a problem hiding this comment.
suggestion (testing): Clarify test intent regarding "unsupported" vs "supported" function rewrites and consider adding a negative case for truly unsupported functions
The renamed test still asserts that rewrites occur for the length() subqueries, so it effectively covers a supported function scenario. If you want to keep the new name, please also add a separate test using a truly unsupported function that asserts no rewrite (and no metric increment). Otherwise, consider reverting/adjusting the name to reflect that this test covers supported-function rewrites.
| @Test | |
| public void testMaterializedViewOptimizationWithScalarFunctionSubquery() | |
| public void testMaterializedViewOptimizationWithUnsupportedFunctionSubquery() | |
| @Test | |
| public void testMaterializedViewOptimizationWithSupportedFunctionSubquery() |
27b209a to
32ac08d
Compare
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 8982f13...1b25a2a. No notifications. |
32ac08d to
1b25a2a
Compare
Description
Adds a test helper
assertMaterializedViewRewriteOccurredthat verifies theoptimizedWithMaterializedViewSubqueryCountruntime metric was incremented during query execution, and migrates existing tests to use it.Motivation and Context
We want to verify rewrites are occurring, this change confirms metrics are emitted during tests in
TestHiveMaterializedViewLogicalPlannerverifying rewrites occurred.Impact
Test Plan
Tests passing with new changes
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Summary by Sourcery
Add a test helper to assert that materialized view rewrites occurred and update materialized view planner tests to validate runtime metrics for rewrites.
Tests: