From 92a70c5e2e0d90221c6227844c112eb7d14cf4f4 Mon Sep 17 00:00:00 2001 From: Reuven Gonzales Date: Mon, 4 Nov 2024 17:36:55 -0800 Subject: [PATCH] More trino related fixes (#2454) --- warehouse/metrics_tools/factory/factory.py | 11 ++++++----- warehouse/metrics_tools/factory/macros.py | 8 +++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/warehouse/metrics_tools/factory/factory.py b/warehouse/metrics_tools/factory/factory.py index b259e4601..9be710990 100644 --- a/warehouse/metrics_tools/factory/factory.py +++ b/warehouse/metrics_tools/factory/factory.py @@ -404,7 +404,7 @@ def generate_rolling_python_model_for_rendered_query( columns = METRICS_COLUMNS_BY_ENTITY[ref["entity_type"]] - kind_common = {"batch_size": 90} + kind_common = {"batch_size": 90, "batch_concurrency": 1} partitioned_by = ("day(metrics_sample_date)",) window = ref.get("window") assert window is not None @@ -452,7 +452,7 @@ def generate_rolling_model_for_rendered_query( columns = METRICS_COLUMNS_BY_ENTITY[ref["entity_type"]] - kind_common = {"batch_size": 1} + kind_common = {"batch_size": 1, "batch_concurrency": 1} partitioned_by = ("day(metrics_sample_date)",) window = ref.get("window") assert window is not None @@ -503,13 +503,14 @@ def generate_time_aggregation_model_for_rendered_query( time_aggregation = ref.get("time_aggregation") assert time_aggregation is not None - kind_options = {"batch_size": 180, "lookback": 7} + kind_common = {"batch_concurrency": 1} + kind_options = {"batch_size": 180, "lookback": 7, **kind_common} partitioned_by = ("day(metrics_sample_date)",) if time_aggregation == "weekly": - kind_options = {"batch_size": 182, "lookback": 7} + kind_options = {"batch_size": 182, "lookback": 7, **kind_common} if time_aggregation == "monthly": - kind_options = {"batch_size": 6, "lookback": 1} + kind_options = {"batch_size": 6, "lookback": 1, **kind_common} partitioned_by = ("month(metrics_sample_date)",) grain = [ diff --git a/warehouse/metrics_tools/factory/macros.py b/warehouse/metrics_tools/factory/macros.py index 69d5d6627..4a5d733a1 100644 --- a/warehouse/metrics_tools/factory/macros.py +++ b/warehouse/metrics_tools/factory/macros.py @@ -219,11 +219,9 @@ def metrics_start(evaluator: MacroEvaluator, _data_type: t.Optional[str] = None) _type=exp.DataType(this=exp.DataType.Type.DATETIME), ), expression=exp.Interval( - this=exp.Paren( - # The interval parameter should be a string or some dialects - # have issues parsing - this=exp.Literal(this=str(rolling_window), is_string=True), - ), + # The interval parameter should be a string or some dialects + # have issues parsing + this=exp.Literal(this=str(rolling_window), is_string=True), unit=exp.Var(this=rolling_unit.upper()), ), )