Closed bmagyarkuti closed 1 month ago
Thank you so much for this fix! It would have been approved earlier, but there's been a lot on.
It looks good - I'll merge main in with this and make sure the remote tests pass before merging.
Fixes https://github.com/dataform-co/dataform/issues/1835 Fixes https://github.com/dataform-co/dataform/issues/1804 Fixes b/371514877
The Bug
This PR fixes a bug where
uniqueKey
assertions on views and incremental tables causeddataform run
to exit with a query error.uniqueKey
assertions on tables, as well as alluniqueKeys
assertions still worked. Affected versions:3.0.1
,3.0.2
. I don't know whether executions on GCP were also affected.Steps to reproduce
1) Create an empty dataform project using version
3.0.1
or3.0.2
of@dataform/core
. 2) Add the following definition:3) Execute
dataform run
. Observe the following error message:The Fix
I don't fully understand what happened. The query complains about an undefined column
TableAssertionsConfig
, and the newly refactored implementations forview
andincremental_table
contain this hardcoded string foruniqueKey
assertions. I'm not sure what the hardcoded string is meant to be referring to. Just replacing the hardcoded string with the user-supplied column names fixes the issue.The Tests
The suite in
core/main_test.ts
tested assertions forviews
,tables
andincremental_table
s, for the following assertions:uniqueKeys
,nonNull
,rowConditions
.uniqueKey
assertions were untested, I assume because they're incompatible with auniqueKeys
assertion. I extended the test suite to also include tests foruniqueKey
assertions, for all three tested table kinds. I worked around the incompatibility by introducing a second sample file. Apart from the differentassertions
block, the second file's contents are identical to the contents of the first file.This has confirmed the bug, as well as the fix.
I nominate @Ekrekr as reviewer.