From 88d6ed5ccfc30a52c23542772db1f34ab5e8c78f Mon Sep 17 00:00:00 2001 From: serramatutu Date: Wed, 2 Oct 2024 15:49:36 +0200 Subject: [PATCH] fixup! refactor: make protocols use the new validations --- dbtsl/api/adbc/protocol.py | 4 ++-- tests/api/adbc/test_protocol.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dbtsl/api/adbc/protocol.py b/dbtsl/api/adbc/protocol.py index 2f565fb..c49d176 100644 --- a/dbtsl/api/adbc/protocol.py +++ b/dbtsl/api/adbc/protocol.py @@ -4,7 +4,7 @@ from dbtsl.api.shared.query_params import ( DimensionValuesQueryParameters, - OrderByDimension, + OrderByGroupBy, OrderByMetric, QueryParameters, validate_query_parameters, @@ -29,7 +29,7 @@ def _serialize_val(cls, val: Any) -> str: m += ".descending(True)" return m - if isinstance(val, OrderByDimension): + if isinstance(val, OrderByGroupBy): d = f'Dimension("{val.name}")' if val.grain: grain_str = val.grain.name.lower() diff --git a/tests/api/adbc/test_protocol.py b/tests/api/adbc/test_protocol.py index 3535842..fec3e74 100644 --- a/tests/api/adbc/test_protocol.py +++ b/tests/api/adbc/test_protocol.py @@ -1,5 +1,5 @@ from dbtsl.api.adbc.protocol import ADBCProtocol -from dbtsl.api.shared.query_params import OrderByDimension, OrderByMetric +from dbtsl.api.shared.query_params import OrderByGroupBy, OrderByMetric from dbtsl.models.time import TimeGranularity @@ -16,18 +16,18 @@ def test_serialize_val_OrderByMetric() -> None: assert ADBCProtocol._serialize_val(OrderByMetric(name="m", descending=True)) == 'Metric("m").descending(True)' -def test_serialize_val_OrderByDimension() -> None: - assert ADBCProtocol._serialize_val(OrderByDimension(name="m", grain=None, descending=False)) == 'Dimension("m")' +def test_serialize_val_OrderByGroupBy() -> None: + assert ADBCProtocol._serialize_val(OrderByGroupBy(name="m", grain=None, descending=False)) == 'Dimension("m")' assert ( - ADBCProtocol._serialize_val(OrderByDimension(name="m", grain=None, descending=True)) + ADBCProtocol._serialize_val(OrderByGroupBy(name="m", grain=None, descending=True)) == 'Dimension("m").descending(True)' ) assert ( - ADBCProtocol._serialize_val(OrderByDimension(name="m", grain=TimeGranularity.DAY, descending=False)) + ADBCProtocol._serialize_val(OrderByGroupBy(name="m", grain=TimeGranularity.DAY, descending=False)) == 'Dimension("m").grain("day")' ) assert ( - ADBCProtocol._serialize_val(OrderByDimension(name="m", grain=TimeGranularity.WEEK, descending=True)) + ADBCProtocol._serialize_val(OrderByGroupBy(name="m", grain=TimeGranularity.WEEK, descending=True)) == 'Dimension("m").grain("week").descending(True)' ) @@ -52,7 +52,7 @@ def test_serialize_query_params_complete_query() -> None: "metrics": ["a", "b"], "group_by": ["dim_c"], "limit": 1, - "order_by": [OrderByMetric(name="a"), OrderByDimension(name="dim_c", grain=None)], + "order_by": [OrderByMetric(name="a"), OrderByGroupBy(name="dim_c", grain=None)], "where": ['{{ Dimension("metric_time").grain("month") }} >= \'2017-03-09\''], "read_cache": False, },