Skip to content

Commit

Permalink
/* PR_START p--misc 02 */ Make optimization levels orderable.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Dec 11, 2024
1 parent 3eb2c95 commit 505c876
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions metricflow/sql/optimizer/optimization_levels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import functools
from dataclasses import dataclass
from enum import Enum
from typing import Tuple
Expand All @@ -13,6 +14,7 @@
from metricflow.sql.optimizer.table_alias_simplifier import SqlTableAliasSimplifier


@functools.total_ordering
class SqlQueryOptimizationLevel(Enum):
"""Defines the level of query optimization and the associated optimizers to apply."""

Expand All @@ -27,6 +29,12 @@ class SqlQueryOptimizationLevel(Enum):
def default_level() -> SqlQueryOptimizationLevel: # noqa: D102
return SqlQueryOptimizationLevel.O5

def __lt__(self, other: SqlQueryOptimizationLevel) -> bool: # noqa: D105
if not isinstance(other, SqlQueryOptimizationLevel):
return NotImplemented

return self.name < other.name


@dataclass(frozen=True)
class SqlGenerationOptionSet:
Expand Down

0 comments on commit 505c876

Please sign in to comment.