Fix uniqueKey
assertions for views, incremental tables
#1836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
3.0.1
or3.0.2
of@dataform/core
.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.