Skip to content

Commit 1019526

Browse files
rboni-dkclaude
andcommitted
fix: truncate timestamps to date in Daily_Record_Ct measure formula
COUNT(DISTINCT col) on timestamp columns counts unique timestamps, not unique dates, producing negative measures (e.g., -1575 instead of 240). Add CAST(col AS DATE) for 7 flavors that were missing date truncation: postgresql, snowflake, databricks, redshift, redshift_spectrum, mssql, trino. BigQuery, Oracle, and SAP HANA already truncated correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3c496c6 commit 1019526

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

testgen/template/dbsetup_test_types/test_types_Daily_Record_Ct.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,55 +52,55 @@ test_types:
5252
test_type: Daily_Record_Ct
5353
sql_flavor: databricks
5454
measure: |-
55-
<%DATEDIFF_DAY;MIN({COLUMN_NAME});MAX({COLUMN_NAME})%>+1-COUNT(DISTINCT {COLUMN_NAME})
55+
<%DATEDIFF_DAY;MIN({COLUMN_NAME});MAX({COLUMN_NAME})%>+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
5656
test_operator: '>'
5757
test_condition: |-
5858
{THRESHOLD_VALUE}
5959
- id: '3005'
6060
test_type: Daily_Record_Ct
6161
sql_flavor: mssql
6262
measure: |-
63-
DATEDIFF(day, MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT {COLUMN_NAME})
63+
DATEDIFF(day, MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
6464
test_operator: '>'
6565
test_condition: |-
6666
{THRESHOLD_VALUE}
6767
- id: '4005'
6868
test_type: Daily_Record_Ct
6969
sql_flavor: postgresql
7070
measure: |-
71-
<%DATEDIFF_DAY;MIN({COLUMN_NAME});MAX({COLUMN_NAME})%>+1-COUNT(DISTINCT {COLUMN_NAME})
71+
<%DATEDIFF_DAY;MIN({COLUMN_NAME});MAX({COLUMN_NAME})%>+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
7272
test_operator: '>'
7373
test_condition: |-
7474
{THRESHOLD_VALUE}
7575
- id: '1005'
7676
test_type: Daily_Record_Ct
7777
sql_flavor: redshift
7878
measure: |-
79-
DATEDIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT {COLUMN_NAME})
79+
DATEDIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
8080
test_operator: '>'
8181
test_condition: |-
8282
{THRESHOLD_VALUE}
8383
- id: '7005'
8484
test_type: Daily_Record_Ct
8585
sql_flavor: redshift_spectrum
8686
measure: |-
87-
DATEDIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT {COLUMN_NAME})
87+
DATEDIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
8888
test_operator: '>'
8989
test_condition: |-
9090
{THRESHOLD_VALUE}
9191
- id: '2005'
9292
test_type: Daily_Record_Ct
9393
sql_flavor: snowflake
9494
measure: |-
95-
DATEDIFF(day, MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT {COLUMN_NAME})
95+
DATEDIFF(day, MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
9696
test_operator: '>'
9797
test_condition: |-
9898
{THRESHOLD_VALUE}
9999
- id: '5005'
100100
test_type: Daily_Record_Ct
101101
sql_flavor: trino
102102
measure: |-
103-
DATE_DIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT {COLUMN_NAME})
103+
DATE_DIFF('DAY', MIN({COLUMN_NAME}), MAX({COLUMN_NAME}))+1-COUNT(DISTINCT CAST({COLUMN_NAME} AS DATE))
104104
test_operator: '>'
105105
test_condition: |-
106106
{THRESHOLD_VALUE}

0 commit comments

Comments
 (0)