SDF supports execution of arbitraryDocumentation Index
Fetch the complete documentation index at: https://docs.sdf.com/llms.txt
Use this file to discover all available pages before exploring further.
scripts which can be executed via the sdf exec command. In this way, you may string multiple commmands together, sequentially.
scripts is a reserved name keyword in the config yml block. Each property in scripts will be an independently executable command.
To execute any script run: sdf exec [SCRIPT_NAME]
Keep in mind:
- If a subcommand exits with an error code, SDF will propagate that error code, and exit with that same error code
- SDF pipes both
stdoutandstderrfrom subcommands - Scripts are run via the
shshell. Color coding will not be preserved.
Getting Started
To configure a custom script, add ascripts element to the config block. Each element in the properties array will become a separately executable command.
sdf exec my_scriptsdf exec other_scriptsdf exec macro_script
Reserved Script Keywords: Pre-Compile, Pre-Run, Post-Compile & Post-Run
In addition to generic scripts, SDF has 4 reserved keywords which will execute scripts natively as part ofsdf compile and sdf run commands.
pre-compile-> When executingsdf compileorsdf checkorsdf report, the script in pre-compile is executed firstpost-compile-> When executingsdf compileorsdf checkorsdf report, the script in post-compile is executed after compile has successfully finishedpre-run-> When executingsdf runorsdf testorsdf stats, the script in pre-run is executed firstpost-run-> When executingsdf runorsdf testorsdf stats, the script in post-run is executed after run has successfully finished
Example
The configuration below utilizes all 4 keywords. Let’s add it to the default workspace fromsdf new
sdf compile, we now run the pre-compile script first, and then post-compile resulting in the below output.
Use Cases
Scripts allow for organization specific workflows- Pre-hooks and Post-hooks -> Run custom logic before or after an SDF command
- Metadata uploading -> Upload SDF’s information schema to a database for further processing.
- Post processing -> Parse metadata for post-run statistics
- Validate results -> Run python, js, shell, or any other process to validate that current changes fit with your current data infrastructure.
User & Root User
Scripts inherit the user of the calling SDF process. As a resultsudo sdf exec ... will run subcommands as sudo as well.
See the below script to validate whether an SDF script is root.