Simply put, SDF allows you to specify
- display formats, as part of CLI options for command line output
- input files (format and location), as part of Data Providers
- output files (format and location), as part of Providers, Data Providers, and Materialization options
- table schemas through inference, files, or Providers
Display Options
SDF writes progress or results on stdout. It provides the developer with a variety of logging and output options to enable scripting, debugging, and other use cases.Command-line options
Inputs / Selectors
All SDF SQL processing commands take a list of targets as input. For example, thecompile and run commands can take targets in multiple formats:
sdf compile catalog.schema.table_nameusing fully qualified namesdf compile table_nameusing table name and inferred fully qualified name from the default catalog and schemasdf compile /path/to/table_name.sqlusing file pathsdf compile catalog.*.*using glob pattern to compile multiple targetssdf compile [No params]using no params compiles the whole workspacesdf compile /path/to/workspaceenables compiling a workspace from outside the workspace directorysdf run -q "SELECT * FROM table_name"using a query string
Outputs
There are 4 commandline options to control the output.-
--show (all | progress | result | none)- Print desired amount of information, i.e., produced tables.allprints progress, results, and any warnings and errorsprogressprints the progress of files as they are compiledresultprints the tables parsed and the schema assocaitednoneprints nothing. This will also prevent theFinished in [n] secondsmessage from displaying at the end of stdout.
-
--format (table | csv | tsv | json | nd-json | yml)- Specifies the table representation on stdout.table(default) is the normal ascii table representation.csvis a CSV representationtsvis a TSV representationjsonis a JSON representationnd-jsonis an ndJSON representationyml, is YML representation
-
--limit <number>- Limits the number of shown rows. Run with--limit 0to show all rows.
Example
Let’s try these options. Start by creating a new SDF workspace with a sample project or change directories into an existing one. The tutorial below uses the lineage sample.1
Install and setup your workspace
To start with a sample workspace lineage ‘new —sample lineage’ will generate a new workspace folder to walk through this example.After running the command, you will see the following output:
Created lineage/checks/check_sink_phone_is_pii.sql
Created lineage/models/knis.sql
Created lineage/models/middle.sql
Created lineage/models/sink.sql
Created lineage/models/source.sql
Created lineage/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.314 secs2
Change Directory
Switch directories into the newly created lineage workspace.
3
Compile lineage Workspace with --show command
Compile the workspace and review the output.Reviewing this output, multiple files have been compiled and SDF has statically analyzed the queries.Add the Reviewing this output, SDF provides progress and table information. SDF reuses model files that have already been compiled and have not been edited.
Alternatively try compiling with various output options:For execution - you may also modulate table output formats. Let’s take the
Working set 4 model files, 1 .sdf file
Compiling lineage.pub.source (./models/source.sql)
Compiling lineage.pub.middle (./models/middle.sql)
Compiling lineage.pub.knis (./models/knis.sql)
Compiling lineage.pub.sink (./models/sink.sql)
Finished 4 models [4 succeeded] in 1.651 secs--show all command to display all information after compilelineage.pub.middle table.4
Display for Individual Tables
To select the output of only one table, use the table name directly after the
compile command.The
compile command can take targets in multiple formats.sdf compile catalog.schema.table_nameusing fully qualified namesdf compile table_nameusing table name and inferred fully qualified namesdf compile /path/to/table_name.sqlusing file pathsdf compile catalog.*.*using glob pattern to compile multiple targetssdf compile [No params]using no params compiles the whole workspace
Schema
Theschema of an external table must be given explicitly, following the ANSI standard SQL syntax or
An example for an explicit table definition looks like this