From 7a497c5fb25e9801c5662314207777e6e1560606 Mon Sep 17 00:00:00 2001 From: BenBirt Date: Thu, 22 Oct 2020 14:34:41 +0100 Subject: [PATCH] Namespace auto-assertions by the schema of their associated table. (#1059) --- core/table.ts | 15 +++++++++------ tests/api/examples.spec.ts | 4 ++-- tests/integration/bigquery.spec.ts | 4 ++-- version.bzl | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/table.ts b/core/table.ts index a488be044..7e8941bed 100644 --- a/core/table.ts +++ b/core/table.ts @@ -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 || []; @@ -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; diff --git a/tests/api/examples.spec.ts b/tests/api/examples.spec.ts index 12a7d5874..c54099862 100644 --- a/tests/api/examples.spec.ts +++ b/tests/api/examples.spec.ts @@ -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." + @@ -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." + diff --git a/tests/integration/bigquery.spec.ts b/tests/integration/bigquery.spec.ts index 3509e7ee0..19bc4fd1e 100644 --- a/tests/integration/bigquery.spec.ts +++ b/tests/integration/bigquery.spec.ts @@ -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": diff --git a/version.bzl b/version.bzl index 490e8b7da..569d74cae 100644 --- a/version.bzl +++ b/version.bzl @@ -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"