Compile your SDF workspace offline without running any queries against your database.
sources
in the root of your workspace. As such, a typical directory structure for this might be:
financials
, in a schema public
, the file structure would optimally look like:
sources
directory. These files should contain the column names and datatypes for the source table. (example below)
raw_customers
(as seen above) with columns like an customerid
and name
. An example of a schema for this source table might look like:
origin
field is set to remote
to indicate that this is a remote source. This is critical, as SDF will still fetch the remote schema unless this attribute is set.columns
field contains a list of column objects, each with a name
and datatype
field. The datatype
field must be a valid SQL datatype that corresponds to the column’s datatype in the remote source.sdftarget
after compiling use remote sources. In the example above, I can simply copy the SDF yml file produced from compilation located at
sdftarget/dbg/table/financials/public/raw_customers.sdf.yml
. Note it’s recommended to remove lots of extra generated metadata like the purpose
, case-policy
, materialization
, and more if using this method.--prefer-local
to the sdf compile
command. This flag will force SDF to compile the model entirely locally, without checking the remote database.
The --prefer-local
flag works by simply setting the incremental mode and snapshot mode variables to true during compilation, thereby replacing the need to check the remote database.
However, let’s say we wanted to compile these models locally but with incremental and snapshot mode off. We can do this by passing extra parameters to the sdf compile
command, specifically --no-incremental-mode
and --no-snapshot-mode
.
Here are four examples and their expected results:
sdf compile --prefer-local
: All incremental models and snapshots will not require a database request to compile. They will compile with incremental mode to true
and snapshot mode to true
sdf compile --prefer-local --no-incremental-mode
: All incremental models and snapshots will not require a database request to compile. They will be compile with incremental mode to false
and snapshot mode to true
sdf compile --prefer-local --no-snapshot-mode
: All incremental models and snapshots will not require a database request to compile. They will be compile with incremental mode to true
and snapshot mode to false
sdf compile --prefer-local --no-incremental-mode --no-snapshot-mode
: All incremental models and snapshots will not require a database request to compile. They will be compile with incremental mode to false
and snapshot mode to false
--no-incremental-mode
and --no-snapshot-mode
will not work to compile locally without --prefer-local
. --prefer-local
is required to prevent a request to the remote database.