Creating a Workspace
To create a new SDF Workspace, run the following command:Β Β Β Β 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Β secshello. The workspace will contain the following files and folder structure:
.
βββΒ models
βΒ Β Β βββΒ main.sql
βββΒ workspace.sdf.yml2Β directories,Β 2Β filesworkspace.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:Β modelsmain.sql, which contains the following SQL:
selectΒ βHelloΒ World!βΒ asΒ messageSDF uses a cache to fingerprint outputs and accelerate recomputation. This cache is by default located in the
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.We refer to SQL statements in SDF as
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.Exploring Your Project
Letβs see just how easy it is to set up SDF and run your first query.1
Static Analysis with `sdf compile`
First, weβll run the core command of SDF: sdf compile.The Your output should look like:As you can see from the output, SDF has statically analyzed the query and determined thereβs a single non-nullable column named
--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.2
Create a New Model
Now, create a new file in the source directory called
main2.sql with the query:main2.sql
3
Lineage with `sdf lineage`
SDF guarantees rich column level lineage. The command below specifies a particular column, in a particular table that we would like to inspect.
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.message4
Execution with `sdf run`
Next, letβs execute the query, using SDF as the database. Weβll execute the query with SDFβs integrated execution runtime, right on your machine.Your output should look like:
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.Quick Links
Tutorials
Try it yourself! Get to know the real value of SDF through our short series of tutorials
Setup SDF
Learn more about setting up SDF in your data stack