soda-sqlserver 4.24.0__tar.gz → 4.26.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-sqlserver
3
- Version: 4.24.0
3
+ Version: 4.26.0
4
4
  Summary: Soda SQL Server V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.24.0
8
+ Requires-Dist: soda-core==4.26.0
9
9
  Requires-Dist: pyodbc
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "soda-sqlserver"
3
- version = "4.24.0"
3
+ version = "4.26.0"
4
4
  description = "Soda SQL Server V4"
5
5
  requires-python = ">=3.10"
6
6
  license = {text = "Proprietary"}
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Soda Data N.V.", email = "info@soda.io"}
9
9
  ]
10
10
  dependencies = [
11
- "soda-core==4.24.0",
11
+ "soda-core==4.26.0",
12
12
  "pyodbc",
13
13
  ]
14
14
 
@@ -5,7 +5,6 @@ from typing import Optional
5
5
 
6
6
  from soda_core.common.data_source_connection import DataSourceConnection
7
7
  from soda_core.common.data_source_impl import DataSourceImpl
8
- from soda_core.common.dataset_identifier import DatasetIdentifier
9
8
  from soda_core.common.logging_constants import soda_logger
10
9
  from soda_core.common.metadata_types import SodaDataTypeName, SqlDataType
11
10
  from soda_core.common.sql_ast import (
@@ -35,7 +34,6 @@ from soda_core.common.sql_ast import (
35
34
  TUPLE,
36
35
  VALUES,
37
36
  WITH,
38
- SqlColumnTerm,
39
37
  seconds_per_time_bucket,
40
38
  )
41
39
  from soda_core.common.sql_dialect import SqlDialect
@@ -102,6 +100,8 @@ class SqlServerDataSourceImpl(DataSourceImpl, model_class=SqlServerDataSourceMod
102
100
  class SqlServerSqlDialect(SqlDialect, sqlglot_dialect="tsql"):
103
101
  DEFAULT_QUOTE_CHAR = "[" # Do not use this! Always use quote_default()
104
102
  SODA_DATA_TYPE_SYNONYMS = ((SodaDataTypeName.TEXT, SodaDataTypeName.VARCHAR),)
103
+ # T-SQL's page window is `OFFSET m ROWS` then `FETCH NEXT n ROWS ONLY`.
104
+ OFFSET_BEFORE_LIMIT: bool = True
105
105
 
106
106
  def __init__(self):
107
107
  super().__init__()
@@ -117,6 +117,11 @@ class SqlServerSqlDialect(SqlDialect, sqlglot_dialect="tsql"):
117
117
  # information_schema constraint views, with the standard PRIMARY KEY (...) DDL.
118
118
  return True
119
119
 
120
+ def get_large_numeric_cast_type_name(self) -> Optional[str]:
121
+ """CAST aggregate args to float: T-SQL's AVG over an integer column returns an
122
+ integer, dropping the fraction."""
123
+ return "float"
124
+
120
125
  def _build_stddev_samp_sql(self, stddev_samp) -> str:
121
126
  # T-SQL names the sample standard deviation aggregate STDEV.
122
127
  return f"STDEV({self.build_expression_sql(stddev_samp.expression)})"
@@ -140,26 +145,6 @@ class SqlServerSqlDialect(SqlDialect, sqlglot_dialect="tsql"):
140
145
  AZURE_SQL_MANAGED_INSTANCE_ENGINE_EDITION,
141
146
  )
142
147
 
143
- def build_select_sql(self, select_elements: list, add_semicolon: bool = True) -> str:
144
- statement_lines: list[str] = []
145
- statement_lines.extend(self._build_cte_sql_lines(select_elements))
146
- statement_lines.extend(self._build_select_sql_lines(select_elements))
147
- statement_lines.extend(self._build_into_sql_lines(select_elements))
148
- statement_lines.extend(self._build_from_sql_lines(select_elements))
149
- statement_lines.extend(self._build_where_sql_lines(select_elements))
150
- statement_lines.extend(self._build_group_by_sql_lines(select_elements))
151
- statement_lines.extend(self._build_order_by_lines(select_elements))
152
-
153
- offset_line = self._build_offset_line(select_elements)
154
- if offset_line:
155
- statement_lines.append(offset_line)
156
-
157
- limit_line = self._build_limit_line(select_elements)
158
- if limit_line:
159
- statement_lines.append(limit_line)
160
-
161
- return "\n".join(statement_lines) + (";" if add_semicolon else "")
162
-
163
148
  def _build_select_sql_lines(self, select_elements: list) -> list[str]:
164
149
  # Use the default implementation, but we need to handle the case where the select elements contain a LIMIT statement.
165
150
  select_sql_lines: list[str] = super()._build_select_sql_lines(select_elements)
@@ -328,33 +313,9 @@ class SqlServerSqlDialect(SqlDialect, sqlglot_dialect="tsql"):
328
313
  def build_cte_values_sql(self, values: VALUES, alias_columns: list[COLUMN] | None) -> str:
329
314
  return "\nUNION ALL\n".join(["SELECT " + self.build_expression_sql(value) for value in values.values])
330
315
 
331
- def select_all_paginated_sql(
332
- self,
333
- dataset_identifier: DatasetIdentifier,
334
- columns: list[SqlColumnTerm],
335
- filter: Optional[str],
336
- order_by: list[SqlColumnTerm],
337
- limit: int,
338
- offset: int,
339
- normalize_key_columns: frozenset[str] = frozenset(),
340
- distinct: bool = False,
341
- ) -> str:
342
- # Same elements as the base paginator (including its distinct x normalize composition),
343
- # but T-SQL spells the page as OFFSET n ROWS FETCH NEXT m ROWS ONLY, so OFFSET leads.
344
- statements = [
345
- *self._paginated_select_statements(
346
- dataset_identifier=dataset_identifier,
347
- columns=columns,
348
- filter=filter,
349
- order_by=order_by,
350
- normalize_key_columns=normalize_key_columns,
351
- distinct=distinct,
352
- ),
353
- OFFSET(offset),
354
- LIMIT(limit),
355
- ]
356
-
357
- return self.build_select_sql(statements)
316
+ # No select_all_paginated_sql override: the base composes the same elements, and the
317
+ # OFFSET-before-FETCH order of the rendered clause is owned by this dialect's
318
+ # build_select_sql — the statement-list order never influenced rendering.
358
319
 
359
320
  def _build_limit_sql(self, limit_element: LIMIT) -> str:
360
321
  return f"FETCH NEXT {limit_element.limit} ROWS ONLY"
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-sqlserver
3
- Version: 4.24.0
3
+ Version: 4.26.0
4
4
  Summary: Soda SQL Server V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.24.0
8
+ Requires-Dist: soda-core==4.26.0
9
9
  Requires-Dist: pyodbc
@@ -0,0 +1,2 @@
1
+ soda-core==4.26.0
2
+ pyodbc
@@ -1,2 +0,0 @@
1
- soda-core==4.24.0
2
- pyodbc