We’re glad to see you here. Today we’re going to install SDF and create a hello world project. Let’s get started.
Created hello/.gitignore
Created hello/models/main.sql
Created hello/workspace.sdf.yml
Welcome to your new SDF Workspace! To help you on your journey:
💡 Join the SDF Community Slack -> https://sdf.com/join
📚 Read the Docs to Get Started -> https://docs.sdf.com/
Finished new in 0.289 secs
hello
. The workspace will contain the following files and folder structure:
.
├── models
│ └── main.sql
└── workspace.sdf.yml2 directories, 2 files
workspace.sdf.yml
file, which is the primary configuration file for your project. It contains the following YML:
workspace:
name: hello
edition: “1.3”
description: “A minimal workspace” includes:
- path: models
main.sql
, which contains the following SQL:
select ‘Hello World!’ as message
sdftarget/
directory.
The cache is machine specific and should not be checked in to git. An appropriate .gitignore
file is created as part of the sdf new
command.models
. Models are SQL statements that will materialized in your data warehouse, or locally with the SDF DB. They differ from tables
as they can be materialized as tables, views, and more based on the configuration. Furthermore, they can be templatized with jinja and SDF SQL variables. SDF recommends specifying one model per file, as each model receives a fully qualified name (database.schema.table
) that can correspond nicely to a directory structure.
See our indexing documentation for more.Static Analysis with `sdf compile`
--show
flag allows you to modulate SDF’s output and the all
option indicates that we would like to see all schemas from all models referenced in the workspace.Working set 1 model file, 1 .sdf file
Compiling hello.pub.main (./models/main.sql)
Finished 1 model [1 succeeded] in 0.871 secsSchema hello.pub.main
┌─────────────┬──────────────────┬────────────┬─────────────┐
│ column_name ┆ data_type ┆ classifier ┆ description │
╞═════════════╪══════════════════╪════════════╪═════════════╡
│ message ┆ varchar not null ┆ ┆ │
└─────────────┴──────────────────┴────────────┴─────────────┘
column
and it’s of type varchar
.
You’ll also see an empty classifier
block in the output. This is for metadata we’ll attach to columns, but we’ll get to that later.Create a New Model
main2.sql
with the query:Lineage with `sdf lineage`
Working set 2 model files, 1 .sdf file
Compiling hello.pub.main (./models/main.sql)
Compiling hello.pub.main2 (./models/main2.sql)
Finished 2 models [2 succeeded] in 0.853 secs
hello.pub.main2.message
│
│ copy
└──────┐
hello.pub.main.message
Execution with `sdf run`
Working set 2 model files, 1 .sdf file
Running hello.pub.main (./models/main.sql)
Running hello.pub.main2 (./models/main2.sql)
Finished 2 models [2 succeeded] in 0.854 secsTable hello.pub.main
┌──────────────┐
│ message │
╞══════════════╡
│ Hello World! │
└──────────────┘
1 rows.Table hello.pub.main2
┌──────────────┐
│ message │
╞══════════════╡
│ Hello World! │
└──────────────┘
1 rows.
sdf.yml
files.