Skip to content

Commit 1503baa

Browse files
Niels-bclaude
andcommitted
test(oracle): schema-check boolean coverage + portable rows_tested_query
- Add an Oracle-gated schema-check test asserting a `data_type: boolean` contract passes (pre-23ai stores BOOLEAN as NUMBER; 23ai native). - Route the rows_tested_query `SELECT NULL` case through select_literal_query (adds FROM DUAL on Oracle), consistent with the other constant queries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ca67d38 commit 1503baa

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

soda-tests/tests/integration/test_failed_rows_rows_tested_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def test_failed_rows_rows_tested_query_returns_null(data_source_test_helper: Dat
270270
FROM {test_table.qualified_name}
271271
WHERE ({end_quoted} - {start_quoted}) > 5
272272
rows_tested_query: |
273-
SELECT NULL
273+
{data_source_test_helper.select_literal_query("NULL")}
274274
""",
275275
)
276276

soda-tests/tests/integration/test_schema_check.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,42 @@
1919
.build()
2020
)
2121

22+
_boolean_schema_test_table_specification = (
23+
TestTableSpecification.builder()
24+
.table_purpose("schema_boolean")
25+
.column_varchar("id")
26+
.column_boolean("is_active")
27+
.build()
28+
)
29+
30+
31+
def test_schema_boolean_data_type_oracle(data_source_test_helper: DataSourceTestHelper):
32+
"""A contract declaring ``data_type: boolean`` must pass the schema check on Oracle, including
33+
pre-23ai (18c/19c) where BOOLEAN has no native SQL type and is stored as NUMBER (which reads
34+
back as ``number``). Guarded by OracleSqlDialect.data_type_names_are_same_or_synonym."""
35+
if data_source_test_helper.data_source_impl.type_name != "oracle":
36+
pytest.skip("Oracle-specific: pre-23ai Oracle stores BOOLEAN as NUMBER")
37+
38+
test_table = data_source_test_helper.ensure_test_table(_boolean_schema_test_table_specification)
39+
40+
data_source_test_helper.enable_soda_cloud_mock(
41+
[
42+
MockResponse(status_code=200, json_object={"fileId": "a81bc81b-dead-4e5d-abff-90865d1e13b1"}),
43+
]
44+
)
45+
46+
data_source_test_helper.assert_contract_pass(
47+
test_table=test_table,
48+
contract_yaml_str=f"""
49+
checks:
50+
- schema:
51+
columns:
52+
- name: id
53+
- name: is_active
54+
data_type: boolean
55+
""",
56+
)
57+
2258

2359
@pytest.mark.parametrize("table_type", [TableType.TABLE, TableType.MATERIALIZED_VIEW, TableType.VIEW])
2460
def test_schema(data_source_test_helper: DataSourceTestHelper, table_type: TableType):

0 commit comments

Comments
 (0)