Documentation
¶
Overview ¶
Package model reads one `.sql` file as a model: a header, a query, and the name the two of them make.
THE CONFIG IS A COMMENT, so the file stays valid SQL. It opens in an editor with highlighting, it runs in a console by hand, and `psql -f` executes it. That is the whole reason the header is not front matter: a model you cannot paste into a client is a model you debug twice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Materialisation ¶
type Materialisation string
Materialisation is what a model becomes in the warehouse.
const ( View Materialisation = "view" Table Materialisation = "table" // Incremental is a TABLE that is added to rather than rebuilt. // // It is a third value and not a flag on Table, because the three differ // in what Build emits, in whether the row count means anything, and in // whether the warehouse is asked a question before the statement is // written. A boolean beside `table` would make every switch read // `Table && !incremental`. Incremental Materialisation = "incremental" )
type Model ¶
type Model struct {
// Schema and Name come from the PATH and never from the header:
// `models/<schema>/<name>.sql` is `<schema>.<name>`. Two places to say
// where a model lands is one place for them to disagree.
Schema string
Name string
Materialised Materialisation
// UniqueKey and Watermark belong to an INCREMENTAL model and to nothing
// else. Both are required there and both are refused elsewhere -- see
// Parse, which says why neither has a default.
UniqueKey []string
Watermark string
Tests []Test
// DependsOn is the explicit override for an edge the extractor cannot
// see -- SQL built at runtime, or one of the forms refs names as its
// limits. Added to what was inferred, never instead of it.
DependsOn []string
// SQL is the query with the header still in it. The header is a comment,
// so the warehouse ignores it and the file that ran is the file on disk.
SQL string
}
Model is one file, read.
Click to show internal directories.
Click to hide internal directories.