Incremental Loading
Overview
Nodes designed for immediate use in incremental data loading.
Installation
- Copy the Package ID:
@coalesce/snowflake/incremental-loading - In Coalesce, open the Workspace where you wish to install the package.
- Go to the Build Setting of the Workspace, tab Packages, and click the Install button on the top right of the page.
- Paste the Package ID, and proceed with the installation process.
Description
Incremental Package
The Coalesce Incremental Package includes:
Incremental Load
The Coalesce Incremental load node is a versatile node that allows you to develop and deploy a Stage table/view in Snowflake where we can perform incremental load in comparison with a persistent table added on top of it.
Incremental Load Node Configuration
Incremental Load Node Properties
| Property | Description |
|---|---|
| Storage Location | Storage Location where the WORK will be created. |
| Node Type | Name of template used to create node objects. |
| Description | A description of the node's purpose. |
| Deploy Enabled | - If TRUE the node will be deployed / redeployed when changes are detected. - If FALSE the node will not be deployed or will be dropped during redeployment. |
Incremental Load Options
| Options | Description |
|---|---|
| Create As | Provides option to choose materialization type as table or view. |
| Filter data based on Persistent table | - True - provides option to perform incremental load. - False - a normal initial load of data from source is done. |
| Persistent table location(required) | The Coalesce storage location. |
| Persistent table name(required) | The table name of the persistent table. |
| Incremental load column(date) | A date column based on which incremental data is loaded. |
Incremental Load Example Workflow
- Add a source node.
- Add the Incremental UDN.
- Leave the 'Filter data based on Persistent Table' option set to False.
- Create the node.
- Add the Persistent table to the view.
- Create and Run the node.
- Go to the Incremental UDN and change the 'Filter data based on Persistent Table' option to true.
- Use the pattern based option to match the persistent table (alter the definition of the UDN, if necessary), or add the table name manually in the last config item.
- Remove the existing (basic) join and use the 'Copy To Editor' to add the new join, including sub-select.
- Re-run the Incremental UDN.
Incremental Load Deployment
Incremental Load Initial Deployment
When deployed for the first time into an environment the Incremental load node of materialization type table will execute the Create State Table.
| Stage | Description |
|---|---|
| Create Stage Table | This will execute a CREATE OR REPLACE statement and create a table in the target environment. When deployed for the first time into an environment the Work node of materialization type view will execute the Create Stage View. |
| Create Stage View | This will execute a CREATE OR REPLACE statement and create a view in the target environment. |
Incremental Load Redeployment
After the Incremental Load has been deployed for the first time into a target environment, subsequent deployments with column level changes or table level changes may result in altering the target Table.
Incremental Load Altering the Stage Tables
There are few column or table changes if made in isolation or all-together will result in an ALTER statement to modify the Work Table in the target environment.
- Changing the table name
- Dropping an existing column
- Altering Column data type
- Adding a new column
The following stages are executed:
| Stage | Description |
|---|---|
| Clone Table | Creates an internal table. |
| Rename Table | Alter Column | Delete Column | Add Column | Edit table description | Alter table statement is executed to perform the alter operation. |
| Swap cloned Table | Upon successful completion of all updates, the clone replaces the main table ensuring that no data is lost. |
| Delete Table | Drops the internal table. |
Incremental Load Recreating the Stage Views
The subsequent deployment of Incremental load node of materialization type view with changes in view definition,adding table description or renaming view results in deleting the existing view and recreating the view.
The following stages are executed:
| Stage | Description |
|---|---|
| Delete View | Delete the view |
| Create View | Create a new view |
Incremental Load Undeployment
If a Incremental load node of materialization type table is deleted from a Workspace, that Workspace is committed to Git and that commit deployed to a higher level environment then the stage table in the target environment will be dropped.
This is executed in two stages:
| Stage | Description |
|---|---|
| Delete Table | Coalesce Internal table is dropped. |
| Delete Table | Target table in Snowflake is dropped. |
If a Incremental load node of materialization type view is deleted from a Workspace, that Workspace is committed to Git and that commit deployed to a higher level environment then the StageView in the target environment will be dropped.
The stage executed:
| Stage | Description |
|---|---|
| Delete View | Drops the existing stage view from target environment. |
Loop Load
The Coalesce node Looped Load dynamically groups incoming source data (incrementally if configured) and loads it into target data by looping through those groups.
It creates "load buckets" dynamically based on a selection of table keys and then uses those buckets to loop through source data and load into a target.
Looped Load Node Configuration
- Looped Load Node Properties
- Looped Load Options
- Looped Load Incremental Load Options
- Looped Load Group Table Options
Looped Load Node Properties
| Property | Description |
|---|---|
| Storage Location | Storage Location where the WORK will be created. |
| Node Type | Name of template used to create node objects. |
| Description | A description of the node's purpose. |
| Deploy Enabled | - If TRUE the node will be deployed / redeployed when changes are detected. - If FALSE the node will not be deployed or will be dropped during redeployment. |
Looped Load Options
| Option | Description |
|---|---|
| Enable tests | This toggle can be enabled to perform data quality tests. |
| Pre-SQL | Any SQL to be executed as a predecessor to the data insert operation can be specified here. |
| Post-SQL | Any SQL to be executed after the data insert operation can be specified here. |
| Load Type | This toggle helps you choose different accepted Load Types from Config. If no load type parameter is specified in the workspace, then it falls back to the config level load type. |
Looped Load Incremental Load Options
| Option | Description |
|---|---|
| Set Incremental Load Options | - True: Prompts for load column based on which incremental data is loaded - False: Incremental processing is not done |
| Incremental Load Column(date) | A date column based on which incremental data is loaded |
| Group Incremental | - True: The data is grouped based on the number of buckets input - False: The data is grouped into a single group |
Looped Load Group Table Options
| Option | Description |
|---|---|
| Dedicated Load History Table | - True: A history table specific to this target table is created by prefixing target table name to TABLE_GROUP_LOAD- False: A history table with common name TABLE_GROUP_LOAD is created |
| Load History Table Location | - Same as Target: The history table is created in the same location as Target table - Utility Schema: The history table is created in the location specified in UtilitySchema parameter |
Looped Load Parameters
The Looped Load node specifies a loadType parameter to perform:
- A full load
- A full reload
- Incremental load
- Reprocess load
Also a parameter utilitySchema can be used to set a target table in a location other than target table location.
{
"loadType_accepted_values": [
"Incremental Load",
"Full Load",
"Reprocess Load",
"Full Reload"
],
"loadType": "Full Load",
"utilitySchema": "TARGET_DB"
}
Key Points on Looped Load Node
- No data gets loaded when
Load_typeis set toReprocess loadif the previous run was all successful. Only when the previous runs has any entries with process status '-1' denoting failure, data gets loaded duringReprocess Load. - The choice of bucket column is crucial for Keybased grouping as choosing a column with distinct unique values affects the performance of data load.
Looped Load Deployment
Looped Load Initial Deployment
When deployed for the first time into an environment the Looped load node will execute the following stages:
| Stage | Description |
|---|---|
| Create Load Group Table | This will execute a CREATE OR REPLACE statement and create a load group table in the target environment. |
| Create Stage Table | This will execute a CREATE OR REPLACE statement and create a table in the target environment. |
Looped Load Redeployment
After the Looped Load has been deployed for the first time into a target environment, subsequent deployments with column level changes or table level changes may result in altering the target Table.
Looped Load Altering the Target Tables
Column or table changes that will result in an ALTER statement to modify the Work Table in the target environment. These changes can be made either in isolation or all together.
- Change in table name
- Dropping existing column
- Alter Column data type
- Adding a new column
The following stages are executed:
| Stage | Description |
|---|---|
| Clone Table | Creates an internal table |
| Rename Table | Alter Column | Delete Column | Add Column | Edit table description | Alter table statement is executed to perform the alter operation accordingly |
| Swap cloned Table | Upon successful completion of all updates, the clone replaces the main table ensuring that no data is lost |
| Delete Table | Drops the internal table |
Looped Load Undeployment
If a Incremental load node of materialization type table is deleted from a Workspace, that Workspace is committed to Git and that commit deployed to a higher level environment then the stage table in the target environment will be dropped.
This is executed in two stages:
| Stage | Description |
|---|---|
| Delete Table | Coalesce Internal table is dropped |
| Delete Table | Target table in Snowflake is dropped |
If a Incremental load node of materialization type view is deleted from a Workspace, that Workspace is committed to Git and that commit deployed to a higher level environment then the StageView in the target environment will be dropped.
The stage executed:
| Stage | Description |
|---|---|
| Delete View | Drops the existing stage view from target environment |