Your Dataform code will likely depend on at least one external (i.e. not produced by Dataform) dataset. Declarations enable you to treat these external datasets as first-class Dataform objects.
Suppose we have an external dataset input.data
.
To declare this dataset you can use SQLX:
1config { 2 type: "declaration", 3 schema: "input", 4 name: "data" 5}
Alternatively you can use the JavaScript API and add multiple declarations in a single file:
1declare({ 2 schema: "input", 3 name: "foo", 4}); 5 6declare({ 7 schema: "input", 8 name: "bar", 9});
Once declared, a dataset can be referenced or resolved in the same way as any other dataset in Dataform.
Assuming the following declaration of the input.data
dataset:
1config { 2 type: "declaration", 3 schema: "input", 4 name: "data" 5}
Other actions may now use the ref()
or resolve()
functions as usual, e.g. ref("data")
or resolve({schema: "input", name: "data"})
.