Skip to content

Commit a9fd0f2

Browse files
author
Hugo Rialan
committed
Fix freshness assertion: test timezone
1 parent 3a240a5 commit a9fd0f2

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

definitions/example.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ const commonAssertionsResult = commonAssertions({
4747
"timeZone": "America/Los_Angeles"
4848
},
4949
"second_table": {
50-
// If timeUnit is not DAY, WEEK, MONTH, QUARTER, or YEAR, dateColumn should be a TIMESTAMP.
51-
// Check here for valid Date time units: https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_diff
52-
// Check here for valid Timestamp time units: https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#timestamp_diff
53-
"dateColumn": "TIMESTAMP(updated_date)",
50+
"dateColumn": "updated_date",
5451
"timeUnit": "HOUR",
5552
"delayCondition": 3,
5653
"timeZone": "-08"

includes/data_freshness_assertions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const createDataFreshnessAssertion = (globalParams, schemaName, tableName, filte
4040
SELECT
4141
${["DAY", "WEEK", "MONTH", "QUARTER", "YEAR"].includes(timeUnit)
4242
? `DATE_DIFF(CURRENT_DATE("${timeZone}"), MAX(${dateColumn}), ${timeUnit})`
43-
: `TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), MAX(${dateColumn}), ${timeUnit})`} AS delay
43+
: `TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), TIMESTAMP(MAX(${dateColumn}),"${timeZone}"), ${timeUnit})`} AS delay
4444
FROM
4545
filtering
4646
)

0 commit comments

Comments
 (0)