Skip to content

Commit

Permalink
refactor: typing public interfaces with order by
Browse files Browse the repository at this point in the history
This commit updates the public `.pyi` files to ensure we use the new
order by spec
  • Loading branch information
serramatutu committed Oct 16, 2024
1 parent bd500f0 commit 18784d8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions dbtsl/api/graphql/client/asyncio.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from contextlib import AbstractAsyncContextManager
from typing import List, Optional, Self
from typing import List, Optional, Self, Union

import pyarrow as pa
from typing_extensions import AsyncIterator, Unpack, overload

from dbtsl.api.shared.query_params import QueryParameters
from dbtsl.api.shared.query_params import OrderByGroupBy, OrderByMetric, QueryParameters
from dbtsl.models import (
Dimension,
Entity,
Expand Down Expand Up @@ -50,7 +50,7 @@ class AsyncGraphQLClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -59,7 +59,7 @@ class AsyncGraphQLClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -73,7 +73,7 @@ class AsyncGraphQLClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand All @@ -82,7 +82,7 @@ class AsyncGraphQLClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand Down
12 changes: 6 additions & 6 deletions dbtsl/api/graphql/client/sync.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from contextlib import AbstractContextManager
from typing import Iterator, List, Optional
from typing import Iterator, List, Optional, Union

import pyarrow as pa
from typing_extensions import Self, Unpack, overload

from dbtsl.api.shared.query_params import QueryParameters
from dbtsl.api.shared.query_params import OrderByGroupBy, OrderByMetric, QueryParameters
from dbtsl.models import (
Dimension,
Entity,
Expand Down Expand Up @@ -50,7 +50,7 @@ class SyncGraphQLClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -59,7 +59,7 @@ class SyncGraphQLClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -73,7 +73,7 @@ class SyncGraphQLClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand All @@ -82,7 +82,7 @@ class SyncGraphQLClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand Down
12 changes: 6 additions & 6 deletions dbtsl/client/asyncio.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from contextlib import AbstractAsyncContextManager
from typing import AsyncIterator, List, Optional
from typing import AsyncIterator, List, Optional, Union

import pyarrow as pa
from typing_extensions import Self, Unpack, overload

from dbtsl.api.adbc.protocol import QueryParameters
from dbtsl.api.shared.query_params import OrderByGroupBy, OrderByMetric, QueryParameters
from dbtsl.models import Dimension, Entity, Measure, Metric, SavedQuery

class AsyncSemanticLayerClient:
Expand All @@ -20,7 +20,7 @@ class AsyncSemanticLayerClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -29,7 +29,7 @@ class AsyncSemanticLayerClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -43,7 +43,7 @@ class AsyncSemanticLayerClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand All @@ -52,7 +52,7 @@ class AsyncSemanticLayerClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand Down
12 changes: 6 additions & 6 deletions dbtsl/client/sync.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from contextlib import AbstractContextManager
from typing import Iterator, List, Optional
from typing import Iterator, List, Optional, Union

import pyarrow as pa
from typing_extensions import Self, Unpack, overload

from dbtsl.api.adbc.protocol import QueryParameters
from dbtsl.api.shared.query_params import OrderByGroupBy, OrderByMetric, QueryParameters
from dbtsl.models import Dimension, Entity, Measure, Metric, SavedQuery

class SyncSemanticLayerClient:
Expand All @@ -20,7 +20,7 @@ class SyncSemanticLayerClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -29,7 +29,7 @@ class SyncSemanticLayerClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> str: ...
Expand All @@ -43,7 +43,7 @@ class SyncSemanticLayerClient:
metrics: List[str],
group_by: Optional[List[str]] = None,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[str, OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand All @@ -52,7 +52,7 @@ class SyncSemanticLayerClient:
self,
saved_query: str,
limit: Optional[int] = None,
order_by: Optional[List[str]] = None,
order_by: Optional[List[Union[OrderByGroupBy, OrderByMetric]]] = None,
where: Optional[List[str]] = None,
read_cache: bool = True,
) -> "pa.Table": ...
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/test_sl_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import pytest
from pytest_subtests import SubTests

from dbtsl import OrderByDimension
from dbtsl import OrderByGroupBy
from dbtsl.client.asyncio import AsyncSemanticLayerClient
from dbtsl.client.base import ADBC, GRAPHQL
from dbtsl.client.sync import SyncSemanticLayerClient
from dbtsl import OrderByDimension

from ..conftest import Credentials
from ..util import maybe_await
Expand Down Expand Up @@ -106,7 +107,7 @@ async def test_client_query_saved_query(api: str, client: BothClients) -> None:
table = await maybe_await(
client.query(
saved_query="order_metrics",
order_by=["metric_time"],
order_by=[OrderByGroupBy(name="metric_time", grain=None)],
where=["1=1"],
limit=1,
read_cache=True,
Expand Down Expand Up @@ -140,7 +141,7 @@ async def test_client_compile_sql_saved_query(client: BothClients) -> None:
sql = await maybe_await(
client.compile_sql(
saved_query="order_metrics",
order_by=["metric_time"],
order_by=[OrderByGroupBy(name="metric_time", grain=None)],
where=["1=1"],
limit=1,
read_cache=True,
Expand Down

0 comments on commit 18784d8

Please sign in to comment.