Testing Nodes
You’ll need to create a SQL SELECT statement to test nodes. If the results match any of the data in the node’s columns, the test will fail. Let's go through a simple example with Snowflake sample data to demonstrate.
Node tests can be run before or after the node's transformations. You can set the run option in the Node test.
Example Node Test
The column C_NATIONKEY
is an integer that corresponds to a specific country, and we know that this number must be positive. No countries in the data set should have a negative number, so we will test for this.
-
Click on Testing.
-
Click on New Test in the Node section to create a new test.
-
In the text box, type in
SELECT * FROM {{ ref_no_link('TARGET','STG_CUSTOMER')}} WHERE C_NATIONKEY < 0
but make sure to replace TARGET with the name of your storage mapping. -
Uncheck the Continue on Failure toggle.
-
Run the node, it should succeed. You can confirm by opening the Results pane and seeing the different stages.
-
Try reversing the
<
to>
, which will match all of our records (nation keys are all positive integers). This will cause the test to fail and the node's data will not be processed.
Node tests can be run before or after the node's transformations, and this is user-configurable.