Abhishek Singh
05/29/2024, 5:35 AMkapa.ai
05/29/2024, 5:35 AM_stg
for every stream replicated. This staging table is used to handle incremental transformations. The process involves:
1. Initial Synchronization: Airbyte replicates all records from the source table into a raw table in the destination database. Then, dbt-generated SQL commands are executed to normalize the raw data into the final destination table ([source](https://airbyte.com/tutorials/incremental-data-synchronization#step-6)).
2. Subsequent Synchronizations: For incremental history + dedupe replication, records are inserted into an existing table rather than creating a new destination table. The process involves copying records from a temporary table into the staging table and ensuring no duplicates by removing existing records before the insertion ([source](https://airbyte.com/tutorials/incremental-data-synchronization#step-7)).
### Example SQL for Incremental Updates
Here is an example of the SQL used for incremental history + dedupe replication:
sql
delete from "postgres"._airbyte_public."table_two_stg"
where (_airbyte_ab_id) in (
select (_airbyte_ab_id)
from "table_two_stg__dbt_tmp140757456406"
);
insert into "postgres"._airbyte_public."table_two_stg" ("_airbyte_table_two_hashid", "id", "name", "updated_at", "_airbyte_ab_id", "_airbyte_emitted_at", "_airbyte_normalized_at")
(
select "_airbyte_table_two_hashid", "id", "name", "updated_at", "_airbyte_ab_id", "_airbyte_emitted_at", "_airbyte_normalized_at"
from "table_two_stg__dbt_tmp140757456406"
);
This SQL ensures that records are copied from a temporary table into the staging table, avoiding duplicates by removing existing records before the insertion.
### Conclusion
Airbyte's current approach to incremental updates should not recreate the final tables every time, provided you are using the incremental deduped history mode. If you are experiencing issues with table recreation, ensure that you are not using the Full Refresh sync mode, as this mode will always perform a full refresh and recreate the tables ([source](https://discuss.airbyte.io/t/76)).kapa.ai
05/29/2024, 5:35 AM_stg
for every stream replicated. This staging table is used to handle incremental transformations. The process involves: 1. Initial Synchronization: Airbyte replicates all records from the source table into a raw table in the destination database. Then, dbt-generated SQL commands are executed to normalize the raw data into the final destination table ([source](https://airbyte.com/tutorials/incremental-data-synchronization#step-6)). 2. Subsequent Synchronizations: For incremental history + dedupe replication, records are inserted into an existing table rather than creating a new destination table. The process involves copying records from a temporary table into the staging table and ensuring no duplicates by removing existing records before the insertion ([source](https://airbyte.com/tutorials/incremental-data-synchronization#step-7)). ### Example SQL for Incremental Updates Here is an example of the SQL used for incremental history + dedupe replication: sql delete from "postgres"._airbyte_public."table_two_stg" where (_airbyte_ab_id) in ( select (_airbyte_ab_id) from "table_two_stg__dbt_tmp140757456406" ); insert into "postgres"._airbyte_public."table_two_stg" ("_airbyte_table_two_hashid", "id", "name", "updated_at", "_airbyte_ab_id", "_airbyte_emitted_at", "_airbyte_normalized_at") ( select "_airbyte_table_two_hashid", "id", "name", "updated_at", "_airbyte_ab_id", "_airbyte_emitted_at", "_airbyte_normalized_at" from "table_two_stg__dbt_tmp140757456406" );
This SQL ensures that records are copied from a temporary table into the staging table, avoiding duplicates by removing existing records before the insertion. ### Conclusion Airbyte's current approach to incremental updates should not recreate the final tables every time, provided you are using the incremental deduped history mode. If you are experiencing issues with table recreation, ensure that you are not using the Full Refresh sync mode, as this mode will always perform a full refresh and recreate the tables ([source](https://discuss.airbyte.io/t/76)). For more detailed information, you can refer to the [Airbyte documentation on incremental synchronization](https://airbyte.com/tutorials/incremental-data-synchronization#step-6) and the [discussion on normalization models](https://discuss.airbyte.io/t/2259).