Working with Jinja in a Scalable Way
Create a new SDF Workspace
sdf new jinjex && cd jinjex
Configure Your Workspace to Use Jinja
workspace.sdf.yml
Add a Jinja Expression to main.sql
sdf compile main
sdf run main
Creating a New Jinja Function
macros
and add a new file macros.jinja
to the folder.Add the new directory to your includes in the workspace.macros.jinja
file add a new function which we’ll call switch_schemajinjex.<function>(params)
Check that the function is included by running sdf compile
. The output should be all green.Using the Jinja function
child.sql
in the /models folder.jinjex.switch_schema
, and creating a new table, in that new schema.Let’s verify that we are now compiling two tables with sdf compile --show all
.We can also easily confirm the lineage for our new table - jinjex.private.child by running sdf lineage jinjex.private.child
sdf run