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
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,15 @@ def __init__(
self.sampler_type: Optional[str] = sampler_type
self.sampler_limit: Optional[Number] = sampler_limit

sql_ast = self.build_query(cte=cte)
self._cte = cte

sql_ast = self.build_query(cte=self._cte, select_clause=SELECT(COUNT(STAR())))
self.sql = self.data_source_impl.sql_dialect.build_select_sql(sql_ast)

def build_query(self, cte: CTE) -> list[SqlExpression]:
def build_query(self, cte: CTE, select_clause: SqlExpression) -> list[SqlExpression]:
query = [
WITH([cte, self.referenced_cte()]),
SELECT(COUNT(STAR())),
select_clause,
FROM(cte.alias).AS(self.referencing_alias),
WHERE.optional(SqlExpressionStr.optional(self.check_filter)),
]
Expand Down
4 changes: 4 additions & 0 deletions soda-tests/src/helpers/data_source_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,15 @@ def assert_contract_fail(
variables: Optional[dict[str, str]] = None,
dwh_data_source_file_path: Optional[str] = None,
extra_data_source_impls: list[DataSourceImpl] = [],
publish_results: bool = True,
) -> ContractVerificationResult:
contract_verification_session_result: ContractVerificationSessionResult = self.verify_contract(
contract_yaml_str=contract_yaml_str,
test_table=test_table,
variables=variables,
dwh_data_source_file_path=dwh_data_source_file_path,
extra_data_source_impls=extra_data_source_impls,
publish_results=publish_results,
)
if contract_verification_session_result.is_ok:
raise AssertionError(f"Expected contract verification failed")
Expand All @@ -544,13 +546,15 @@ def assert_contract_warn(
variables: Optional[dict[str, str]] = None,
dwh_data_source_file_path: Optional[str] = None,
extra_data_source_impls: list[DataSourceImpl] = [],
publish_results: bool = True,
) -> ContractVerificationResult:
contract_verification_session_result: ContractVerificationSessionResult = self.verify_contract(
contract_yaml_str=contract_yaml_str,
test_table=test_table,
variables=variables,
dwh_data_source_file_path=dwh_data_source_file_path,
extra_data_source_impls=extra_data_source_impls,
publish_results=publish_results,
)
if not contract_verification_session_result.is_warned:
raise AssertionError(f"Expected contract verification warned")
Expand Down