-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update API for requesting dataflow plan optimization
In order to fully support predicate pushdown via the DataflowPlanOptimizer framework we need two things: 1. Support for optimization in distinct values queries 2. The ability to share components between the DataflowPlanBuilder and the PredicatePushdownOptimizer This update addresses both of these concerns by doing a small restructure of the DataflowPlanBuilder interface for accepting optimizers. Instead of accepting a sequence of optimizer instances, the build_plan method will now accept a sequence of optimization enumerations. Those will then be converted to instances via the factory class added in this change. From there the update to the distinct values plan method signature was a trivial addition. Note - snapshot updates should be limited to ID numbers due to the added call to the DataflowPlanNodeOutputDataSetResolver in the distinct values plan.
- Loading branch information
Showing
11 changed files
with
100 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
metricflow/dataflow/optimizer/dataflow_optimizer_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import List, Sequence | ||
|
||
from dbt_semantic_interfaces.enum_extension import assert_values_exhausted | ||
|
||
from metricflow.dataflow.optimizer.dataflow_plan_optimizer import DataflowPlanOptimizer | ||
from metricflow.dataflow.optimizer.predicate_pushdown_optimizer import PredicatePushdownOptimizer | ||
from metricflow.dataflow.optimizer.source_scan.source_scan_optimizer import SourceScanOptimizer | ||
|
||
|
||
class DataflowPlanOptimization(Enum): | ||
"""Enumeration of optimization types available for execution.""" | ||
|
||
PREDICATE_PUSHDOWN = "predicate_pushdown" | ||
SOURCE_SCAN = "source_scan" | ||
|
||
|
||
class DataflowPlanOptimizerFactory: | ||
"""Factory class for initializing an enumerated set of optimizers. | ||
This allows us to centralize initialization and, most importantly, share class instances with cached high cost | ||
processing between the DataflowPlanBuilder and the optimizer instances requiring that functionality. | ||
""" | ||
|
||
def get_optimizers(self, optimizations: Sequence[DataflowPlanOptimization]) -> Sequence[DataflowPlanOptimizer]: | ||
"""Initializes and returns a sequence of optimizers matching the input optimization requests.""" | ||
optimizers: List[DataflowPlanOptimizer] = [] | ||
for optimization in optimizations: | ||
if optimization is DataflowPlanOptimization.SOURCE_SCAN: | ||
optimizers.append(SourceScanOptimizer()) | ||
elif optimization is DataflowPlanOptimization.PREDICATE_PUSHDOWN: | ||
optimizers.append(PredicatePushdownOptimizer()) | ||
else: | ||
assert_values_exhausted(optimization) | ||
|
||
return tuple(optimizers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters