dataform: Add assertions as dependencies

Hi Experts, 

I am following Add assertions as dependencies. 

I have created A.sqlx:

 

 

 

config {
  type: "table",
  assertions: {
    uniqueKey: ["user_id"],
    nonNull: ["user_id", "customer_id"],
  },
  name: "A"
}

SELECT * from `dataset1.source_table1`

 

 

 

B.sqlx:

 

 

 

config {
    type: "table",
    dependencies: ["A_uniqueKey", "A_nonNull"],
    name: "B"
}

SELECT
  *
FROM
  ${ref("A")}

 

 

 

However, there are erors as below:

Missing dependency detected: Action "gcp_proj1.dataform.B" depends on "{"name":"A_uniqueKey"}" which does not exist

Missing dependency detected: Action "gcp_proj1.dataform.B" depends on "{"name":"A_nonNull"}" which does not exist

Anything wrong with my codes?

Many thanks. 

Lee

Solved Solved
0 3 202
1 ACCEPTED SOLUTION

It has been confirmed that the official document is outdated. 

View solution in original post

3 REPLIES 3

When Dataform executes A.sqlx, it creates views for those assertions you listed in the config{} block.
The first thing I would make sure is to execute A.sqlx on its own to ensure those views get created. 
Second thing would be make sure I copy and pasted the exact name of the assertion from A.slqx and paste it into the dependencies block.
You don't need the fully qualified name that includes the project and dataset. Only need the table name.

Example in green.

DataEngineer_0-1711975346024.png

 

Hi, 

It did work as you suggested. 
But I am still wondering why the codes in the official docs did not work. 

Thanks. 

It has been confirmed that the official document is outdated.