Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Fixes-20250721-115455.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixes
body: Remove unneeded subquery, which creates invalid SQL for some dialects.
time: 2025-07-21T11:54:55.027236-07:00
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
dist/
.ruff_cache
.pytest_cache
venv/
uv.lock

# ignore gql schema files
**/*.gql
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you want to contribute by submitting code, this section will explain how to s
### Setting up your environment

1. We use [hatch](https://hatch.pypa.io/) as the dependency and environment manager. Make sure you install it via one of the methods described [here](https://hatch.pypa.io/latest/install/).
2. We use [lefthook](https://github.com/evilmartians/lefthook/) for Git hooks management. The first time you clone the repo, run `lefthook install` to setup the git hooks.
2. We use [lefthook](https://github.com/evilmartians/lefthook/) for Git hooks management. The first time you clone the repo, run `pip install lefthook && lefthook install` to setup the git hooks.

Hatch will manage your environments for you. Check out the list of available environments in [`pyproject.toml`](./pyproject.toml). Here follows a brief explanation of what they are for:
- `default`: run only basic scripts, no dependencies installed
Expand Down
4 changes: 2 additions & 2 deletions dbtsl/api/adbc/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def get_query_sql(cls, params: QueryParameters) -> str:
strict_params_dict = {field: getattr(strict_params, field) for field in params_fields}

serialized_params = cls._serialize_params_dict(strict_params_dict, params_fields)
return f"SELECT * FROM {{{{ semantic_layer.query({serialized_params}) }}}}"
return f"{{{{ semantic_layer.query({serialized_params}) }}}}"

@classmethod
def get_dimension_values_sql(cls, params: DimensionValuesQueryParameters) -> str:
"""Get the SQL that will be sent via Arrow Flight to the server based on dimension values query parameters."""
serialized_params = cls._serialize_params_dict(params, list(DimensionValuesQueryParameters.__optional_keys__))
return f"SELECT * FROM {{{{ semantic_layer.dimension_values({serialized_params}) }}}}"
return f"{{{{ semantic_layer.dimension_values({serialized_params}) }}}}"
9 changes: 3 additions & 6 deletions tests/api/adbc/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ def test_serialize_query_params_complete_query() -> None:

def test_get_query_sql_simple_query() -> None:
sql = ADBCProtocol.get_query_sql(params={"metrics": ["a", "b"], "order_by": ["-a"]})
expected = (
'SELECT * FROM {{ semantic_layer.query(metrics=["a","b"],'
'order_by=[Metric("a").descending(True)],read_cache=True) }}'
)
expected = '{{ semantic_layer.query(metrics=["a","b"],order_by=[Metric("a").descending(True)],read_cache=True) }}'
assert sql == expected


Expand All @@ -100,13 +97,13 @@ def test_get_query_sql_group_by_param() -> None:
}
)
expected = (
"SELECT * FROM {{ semantic_layer.query("
"{{ semantic_layer.query("
'group_by=[Dimension("c").grain("day"),Entity("d").grain("week")],metrics=["a","b"],read_cache=True) }}'
)
assert sql == expected


def test_get_query_sql_dimension_values_query() -> None:
sql = ADBCProtocol.get_dimension_values_sql(params={"metrics": ["a", "b"]})
expected = 'SELECT * FROM {{ semantic_layer.dimension_values(metrics=["a","b"]) }}'
expected = '{{ semantic_layer.dimension_values(metrics=["a","b"]) }}'
assert sql == expected
Loading