Skip to content

Commit

Permalink
Namespace auto-assertions by the schema of their associated table. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBirt authored Oct 22, 2020
1 parent bd589a2 commit 7a497c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
15 changes: 9 additions & 6 deletions core/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,9 @@ export class Table {
if (!!assertions.uniqueKey) {
const indexCols =
typeof assertions.uniqueKey === "string" ? [assertions.uniqueKey] : assertions.uniqueKey;
this.session.assert(`${this.proto.target.name}_assertions_uniqueKey`, ctx =>
this.session.adapter().indexAssertion(ctx.ref(this.proto.target), indexCols)
this.session.assert(
`${this.proto.target.schema}_${this.proto.target.name}_assertions_uniqueKey`,
ctx => this.session.adapter().indexAssertion(ctx.ref(this.proto.target), indexCols)
).proto.parentAction = this.proto.target;
}
const mergedRowConditions = assertions.rowConditions || [];
Expand All @@ -601,10 +602,12 @@ export class Table {
nonNullCols.forEach(nonNullCol => mergedRowConditions.push(`${nonNullCol} IS NOT NULL`));
}
if (!!mergedRowConditions && mergedRowConditions.length > 0) {
this.session.assert(`${this.proto.target.name}_assertions_rowConditions`, ctx =>
this.session
.adapter()
.rowConditionsAssertion(ctx.ref(this.proto.target), mergedRowConditions)
this.session.assert(
`${this.proto.target.schema}_${this.proto.target.name}_assertions_rowConditions`,
ctx =>
this.session
.adapter()
.rowConditionsAssertion(ctx.ref(this.proto.target), mergedRowConditions)
).proto.parentAction = this.proto.target;
}
return this;
Expand Down
4 changes: 2 additions & 2 deletions tests/api/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ suite("examples", () => {
t.name ===
"tada-analytics." +
schemaWithSuffix("df_integration_test_assertions") +
".example_table_with_tags_assertions_uniqueKey"
".df_integration_test_example_table_with_tags_assertions_uniqueKey"
)[0];
expect(cleanSql(exampleTableWithTagsUniqueKeyAssertion.query)).equals(
"select * from (select sample, count(1) as index_row_count from `tada-analytics." +
Expand All @@ -329,7 +329,7 @@ suite("examples", () => {
t.name ===
"tada-analytics." +
schemaWithSuffix("df_integration_test_assertions") +
".example_table_with_tags_assertions_rowConditions"
".df_integration_test_example_table_with_tags_assertions_rowConditions"
)[0];
expect(cleanSql(exampleTableWithTagsRowConditionsAssertion.query)).equals(
"select 'sample is not null' as failing_row_condition, * from `tada-analytics." +
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/bigquery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ suite("@dataform/integration/bigquery", { parallel: true }, ({ before, after })
"dataform-integration-tests.df_integration_test_run_caching.sample_data_2":
dataform.ActionResult.ExecutionStatus.SUCCESSFUL,
// Should run because they are auto assertions.
"dataform-integration-tests.df_integration_test_assertions_run_caching.sample_data_2_assertions_uniqueKey":
"dataform-integration-tests.df_integration_test_assertions_run_caching.df_integration_test_sample_data_2_assertions_uniqueKey":
dataform.ActionResult.ExecutionStatus.SUCCESSFUL,
"dataform-integration-tests.df_integration_test_assertions_run_caching.sample_data_2_assertions_rowConditions":
"dataform-integration-tests.df_integration_test_assertions_run_caching.df_integration_test_sample_data_2_assertions_rowConditions":
dataform.ActionResult.ExecutionStatus.SUCCESSFUL,
// Should run because an input to dataset has changed in the warehouse.
"dataform-integration-tests.df_integration_test_run_caching.depends_on_sample_data_3":
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# NOTE: If you change the format of this line, you must change the bash command
# in /scripts/publish to extract the version string correctly.
DF_VERSION = "1.14.1"
DF_VERSION = "1.14.2"

0 comments on commit 7a497c5

Please sign in to comment.