Skip to content

Commit 12aedd4

Browse files
feat(query): add dialect parameter to query request (#174)
Co-authored-by: hotdata-automation[bot] <267177015+hotdata-automation[bot]@users.noreply.github.com>
1 parent c044475 commit 12aedd4

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- feat(query): add dialect parameter to query request
13+
1014
## [0.10.0] - 2026-08-18
1115

1216
### Removed

‎docs/QueryRequest.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Name | Type | Description | Notes
1111
**database_id** | **str** | Database to scope the query to (its id). Alternative to the &#x60;X-Database-Id&#x60; header — exactly one source must be provided. If both this field and the header are set and they disagree, the request is rejected with a 400. | [optional]
1212
**default_catalog** | **str** | Catalog that unqualified table references resolve against within the query&#39;s database scope. Must name a catalog visible in the database (&#x60;default&#x60;, an attached catalog alias, or a system catalog). Defaults to &#x60;default&#x60; when omitted. | [optional]
1313
**default_schema** | **str** | Schema that unqualified table references resolve against within the query&#39;s database scope. Defaults to &#x60;main&#x60; when omitted. Existence is not validated up front — an unknown schema surfaces as a \&quot;table not found\&quot; error at planning time. | [optional]
14+
**dialect** | **str** | SQL dialect the &#x60;sql&#x60; field is written in. One of &#x60;hotsql&#x60; (the default), &#x60;duckdb&#x60;, &#x60;postgres&#x60;, or &#x60;snowflake&#x60;. When set to anything other than &#x60;hotsql&#x60;, the query is translated to HotSQL before it runs, so you can use idioms from that dialect (for example Snowflake &#x60;IFF(...)&#x60; or Postgres &#x60;MOD(a, b)&#x60;). Only read-only queries are accepted. An unrecognized value is rejected with a 400. | [optional]
1415
**sql** | **str** | |
1516

1617
## Example

‎hotdata/models/query_request.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ class QueryRequest(BaseModel):
3333
database_id: Optional[StrictStr] = Field(default=None, description="Database to scope the query to (its id). Alternative to the `X-Database-Id` header — exactly one source must be provided. If both this field and the header are set and they disagree, the request is rejected with a 400.")
3434
default_catalog: Optional[StrictStr] = Field(default=None, description="Catalog that unqualified table references resolve against within the query's database scope. Must name a catalog visible in the database (`default`, an attached catalog alias, or a system catalog). Defaults to `default` when omitted.")
3535
default_schema: Optional[StrictStr] = Field(default=None, description="Schema that unqualified table references resolve against within the query's database scope. Defaults to `main` when omitted. Existence is not validated up front — an unknown schema surfaces as a \"table not found\" error at planning time.")
36+
dialect: Optional[StrictStr] = Field(default=None, description="SQL dialect the `sql` field is written in. One of `hotsql` (the default), `duckdb`, `postgres`, or `snowflake`. When set to anything other than `hotsql`, the query is translated to HotSQL before it runs, so you can use idioms from that dialect (for example Snowflake `IFF(...)` or Postgres `MOD(a, b)`). Only read-only queries are accepted. An unrecognized value is rejected with a 400.")
3637
sql: StrictStr
37-
__properties: ClassVar[List[str]] = ["async", "async_after_ms", "database_id", "default_catalog", "default_schema", "sql"]
38+
__properties: ClassVar[List[str]] = ["async", "async_after_ms", "database_id", "default_catalog", "default_schema", "dialect", "sql"]
3839

3940
model_config = ConfigDict(
4041
populate_by_name=True,
@@ -95,6 +96,11 @@ def to_dict(self) -> Dict[str, Any]:
9596
if self.default_schema is None and "default_schema" in self.model_fields_set:
9697
_dict['default_schema'] = None
9798

99+
# set to None if dialect (nullable) is None
100+
# and model_fields_set contains the field
101+
if self.dialect is None and "dialect" in self.model_fields_set:
102+
_dict['dialect'] = None
103+
98104
return _dict
99105

100106
@classmethod
@@ -112,6 +118,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
112118
"database_id": obj.get("database_id"),
113119
"default_catalog": obj.get("default_catalog"),
114120
"default_schema": obj.get("default_schema"),
121+
"dialect": obj.get("dialect"),
115122
"sql": obj.get("sql")
116123
})
117124
return _obj

‎test/test_query_request.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def make_instance(self, include_optional) -> QueryRequest:
4141
database_id = 'dbid6lguax1dxn9y1xj5gxnameyywl',
4242
default_catalog = 'default',
4343
default_schema = 'main',
44+
dialect = 'hotsql',
4445
sql = 'SELECT customer_id, sum(amount) AS total FROM orders GROUP BY customer_id ORDER BY total DESC LIMIT 10'
4546
)
4647
else:

0 commit comments

Comments
 (0)