Expand SDF Built-in Libraries with custom logic
Open an SDF workspace
tests
sample workspace.
However, you can always use your existing SDF workspace to follow along.To create the tests
workspace, run the following command:Create a New Libs Folder
my_lib
,
but any name would work. This is where we will add our custom logic in
later steps.If you are using the tests
example, your workspace should look like this:Copy SDF's Built-in Lib
sdfTarget
.
If you don’t have an sdfTarget
directory, all you need to do is
to compile your workspace:sdfTarget
in your
workspace:sdfTarget/dbg/.lib
.Let’s copy sdf_test
to our new custom libraries folder:sdf_test
,
or change it if there’s another name you’d prefer to use.Add Custom Library to the Workspace YML
workspace.sdf.yml
file, let’s add the following section:sdf_test
.
However, we can also choose a different name to our library. If
we decide to do so, we’ll need to indicate it in the defaults.Let’s assume we call the new tests library new_tests
:Expand Your Lib
my_lib/sdf_test/macro/test.jinja
.
If you changed any folder names, make sure to apply the changes to locate
the relevant file.Copy the following macro to the top of your custom tests lib:Try It!
src_metadata/raw_inapp_events.sdf.yml
, add our new custom test
to the column event_name
:sdftarget/dbg/preprocessed/tests_workspace/pub/test_raw_inapp_events.sql
.
Notice our custom logic in the compiled query: