Upsert-merge for Firebolt
Using Data Integration, Firebolt users can perform an Upsert-Merge data using views and the flip-flop method.
Firebolt views design
Firebolt represents the table names you define in your rivers as views in your database. To ensure maximum availability, this design alternates between two tables—suffixed with _flip and _flop after every successful river run.
For example, the table name is facebook_insights, and the underlying tables are facebook_insights_flip and facebook_insights_flop.
You can find the name of the current underlying table from the views schema by exploring the DDL of the view.
If you want to make changes, such as adding additional AGGREGATION or JOIN indexes to your tables, you can do so by querying the information_schema views and extracting the DDL. Then, add the new index to both the original table and the other table.
You should make all other changes, such as partitions or primary indexes, only via the Data Integration console.
Flip/Flop Flow
You can find additional details on the Flip/Flop Flow.
- New data arrives:
- If there is no current target view
- Create a flip table with the new data.
- Create a view over the flip table.
- If there is only a flip table:
- Create a flop table.
- Drop the current view.
- Create a new view over the flop table.Â
- If both flip/flop tables exist:
- Check the current table that the view depends on.
- If flip
- Drop flop
- Recreate flop with new data
- Drop current view
- Create a view over flop
- If flop
- Drop flip
- Recreate the flip with new data
- Drop current view
- Create a view over flip
Flip/Flop diagram
-a239b075d07fb3cfd4339f9bb46c3950.jpg)