<@U04S8PLJWMT> Does airbyte use the raw table or t...
# ask-ai
o
@kapa.ai Does airbyte use the raw table or the scd table to create the final deduplicated table
k
Airbyte uses the SCD (history) table to create the final deduplicated table, not the raw table. The deduplicated table (e.g., table_two) is populated by selecting only the active rows (where _airbyte_active_row = 1) from the SCD table (e.g., table_two_scd). The raw table is used as an initial staging area, but the final deduplication logic is applied on the SCD table, and only those results are inserted into the deduplicated table. This process ensures that only the latest version of each record (per primary key) appears in the deduplicated table, while the SCD table maintains the full history of changes. > This code is quite simple, as all it does is copies the rows where _airbyte_active_row = 1 from the history table called table_two_scd into the deduped tabled called table_two. > > If there are multiple historical copies of a record in the history table (table_two_scd), only the record from the most recent sync will have an _airbyte_active_row value of 1. Therefore, by copying only the currently active row from the history table called table_two_scd, the data that is copied into table_two is deduplicated. [Explore Airbyte’s incremental data synchronization](https://airbyte.com/tutorials/incremental-data-synchronization#step-7)
o
@kapa.ai then how is my deduplicated table up to date, while the scd table isnt since upgraded to airbyte 2, and I also have 2 versions of the raw table the old one matches the date of stopping as the scd table while the new one is up to date, doesnt that mean that the deduplicated table depends on the raw table not the sc
k
A message from kapa.ai
Based on the information in the knowledge sources, after upgrading to Destinations V2, Airbyte changes how raw tables are managed, but the deduplicated table (final table) is still created from the SCD (history) table, not directly from the raw table. Here’s what happens during and after the upgrade: - Pre-existing raw tables, SCD tables, and "unnested" tables are left untouched after the upgrade. They are no longer kept up-to-date by Airbyte syncs. New raw tables are created in the new format and are kept up-to-date going forward. - The new deduplicated table is created from the new SCD table, which is itself generated from the new raw table. The deduplication logic still relies on the SCD table, not directly on the raw table. - If your SCD table stopped updating at the time of the upgrade, but your deduplicated table is up to date, this suggests that the deduplicated table is now being built from the new SCD table (which is being updated from the new raw table), not the old SCD table. The old SCD table and old raw table are no longer updated, but remain in your database for reference or manual cleanup. > Pre-existing raw tables, SCD tables and "unnested" tables will always be left untouched. You can delete these at your convenience, but these tables will no longer be kept up-to-date by Airbyte syncs. [Upgrading to Destinations V2](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2#quick-start-to-upgrading) > The new raw tables will be updated to the new Destinations V2 format. ... The new raw tables will be typed and de-duplicated according to the Destinations V2 format. Once typing and de-duplication has completed successfully, your previous final table will be replaced with the updated data. [Upgrading to Destinations V2](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2#quick-start-to-upgrading) In summary: - The deduplicated table is still built from the SCD table, not directly from the raw table. - After upgrading, only the new SCD and raw tables are kept up to date; the old ones are static. - If your deduplicated table is up to date, it is being built from the new SCD table, which is being updated from the new raw table. If you see two versions of the raw table and SCD table, only the new ones are active. The deduplicated table does not depend directly on the raw table, but on the SCD table generated from the current raw table.
o
but the scd table only has 1 version which is the old and doesnt work
@kapa.ai but the scd table only has 1 version which is the old and doesnt work
k
A message from kapa.ai
Thank you for clarifying. Based on your description and the knowledge sources, if your SCD (history) table only has the old version and is not being updated after upgrading to Destinations V2, but your deduplicated table is up to date, this suggests a change in Airbyte’s behavior with Destinations V2. The knowledge sources confirm that after upgrading to Destinations V2, pre-existing SCD tables are left untouched and are no longer updated. Airbyte now manages data differently, and the new deduplication and typing logic is applied directly to the new raw tables, not through the legacy SCD tables: > Pre-existing raw tables, SCD tables and "unnested" tables will always be left untouched. You can delete these at your convenience, but these tables will no longer be kept up-to-date by Airbyte syncs. [Upgrading to Destinations V2](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2#quick-start-to-upgrading) Additionally, the documentation states: > This version includes ... Removal of SCD tables [Postgres Migration Guide](https://docs.airbyte.com/integrations/destinations/postgres-migrations#upgrading-to-200) What this means: - After upgrading to Destinations V2, Airbyte no longer updates the old SCD tables. - The deduplicated (final) table is now maintained by Airbyte’s new internal logic, which does not rely on the legacy SCD table. - The new deduplication and typing is performed directly from the new raw tables, and the SCD table is no longer part of the sync process. In summary: If your SCD table is not being updated, but your deduplicated table is, this is expected behavior after upgrading to Destinations V2. The deduplicated table is now maintained independently of the old SCD table, which is no longer used or updated by Airbyte. If you need to keep a history of changes (SCD), you may need to implement this logic yourself or use downstream tools, as Airbyte Destinations V2 no longer creates or maintains SCD tables.
o
@kapa.ai can you check this airbyte docs link Upgrading to Destinations V2 | Airbyte Docs it says that the raw table will be typed and deduplicated to create the final version
k
A message from kapa.ai
Yes, you are correct. According to the [Upgrading to Destinations V2](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2#quick-start-to-upgrading) documentation, after upgrading, the process is as follows: > The new raw tables will be updated to the new Destinations V2 format. > The new raw tables will be updated with any new data since the last sync, like normal. > The new raw tables will be typed and de-duplicated according to the Destinations V2 format. > Once typing and de-duplication has completed successfully, your previous final table will be replaced with the updated data. This means that, in Destinations V2, Airbyte directly types and deduplicates data from the new raw tables to create the final table. The SCD (history) tables are no longer part of the sync process and are not updated after the upgrade. This matches your observation that the deduplicated table is up to date while the SCD table is not. So, in Destinations V2, the deduplicated (final) table is indeed created from the (new) raw table, not from the SCD table.