<@U04S8PLJWMT> I'm pretty stuck... using `full_ref...
# ask-ai
l
@kapa.ai I'm pretty stuck... using
full_refresh_append
streams in Airbyte I'm using terraform to maintain my resources... terrafrom often causes a connection to
delete/create
rather than update in place... this makes knowing which data in the full refresh appened is form the "latest sync" challenging! Specifically because
_airbyte_generation_id
gets reset... Simple changes cause terraform like this:
Copy code
# module.airbyte.airbyte_connection.privatei_to_dw_raw_bq must be replaced
-/+ resource "airbyte_connection" "privatei_to_dw_raw_bq" {
      ~ configurations                       = {
          ~ streams = [
              - {
                  - cursor_field    = [
                      - "date",
                    ] -> null
                  - mappers         = [] -> null
                  - name            = "Index Values" -> null
                  - primary_key     = [
                      - [
                          - "indexValueID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [
                      - "investmentRevisedDate",
                    ] -> null
                  - mappers         = [] -> null
                  - name            = "Investments" -> null
                  - primary_key     = [
                      - [
                          - "investmentID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Assets" -> null
                  - primary_key     = [
                      - [
                          - "assetID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Indexes" -> null
                  - primary_key     = [
                      - [
                          - "indexID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Investment Cash Transactions" -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Investment Commitment History" -> null
                  - primary_key     = [
                      - [
                          - "investmentCommitmentHistoryID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Investment Transactions" -> null
                  - primary_key     = [
                      - [
                          - "transactionID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Investment Valuation" -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [] -> null
                  - mappers         = [] -> null
                  - name            = "Portfolios" -> null
                  - primary_key     = [
                      - [
                          - "portfolioID",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              + {
                  + cursor_field    = [
                      + "date",
                    ]
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Index Values"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "indexValueID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = [
                      + "investmentRevisedDate",
                    ]
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Investments"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "investmentID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Assets"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "assetID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Indexes"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "indexID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Investment Cash Transactions"
                  + namespace       = (known after apply)
                  + primary_key     = (known after apply)
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Investment Commitment History"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "investmentCommitmentHistoryID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Investment Transactions"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "transactionID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Investment Valuation"
                  + namespace       = (known after apply)
                  + primary_key     = (known after apply)
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
              + {
                  + cursor_field    = []
                  + include_files   = (known after apply)
                  + mappers         = []
                  + name            = "Portfolios"
                  + namespace       = (known after apply)
                  + primary_key     = [
                      + [
                          + "portfolioID",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "full_refresh_append"
                },
            ]
        }
      ~ connection_id                        = "f1ec7d7e-fd13-4d90-940c-7917ced83e83" -> (known after apply)
      ~ created_at                           = 1752438965 -> (known after apply)
      ~ data_residency                       = "auto" -> (known after apply)
        name                                 = "Private I -> BigQuery DW Raw"
      ~ schedule                             = {
          + basic_timing    = (known after apply)
          + cron_expression = (known after apply)
            # (1 unchanged attribute hidden)
        }
      ~ source_id                            = "8e8521e9-5d07-4154-a329-40223d00b5bb" -> (known after apply)
      ~ status                               = "active" -> (known after apply)
      ~ workspace_id                         = "5dc9466d-4e0a-4a9f-851e-eb464431662f" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

  # module.airbyte.airbyte_declarative_source_definition.arch will be updated in-place
  ~ resource "airbyte_declarative_source_definition" "arch" {
      ~ id           = "84ccd075-6c80-444d-97ff-34f072c41a98" -> (known after apply)
        name         = "Arch"
      ~ version      = 4 -> 1
        # (2 unchanged attributes hidden)
    }
Copy code
# module.airbyte.airbyte_source_custom.arch must be replaced
-/+ resource "airbyte_source_custom" "arch" {
      ~ configuration       = (sensitive value)
      ~ created_at          = 1752438942 -> (known after apply)
      ~ definition_id       = "84ccd075-6c80-444d-97ff-34f072c41a98" -> (known after apply)
        name                = "Arch"
      + resource_allocation = (known after apply)
      ~ source_id           = "ae63e996-3d1d-4e2e-b348-e5a52ddca8d2" -> (known after apply)
      ~ source_type         = null -> (known after apply)
        # (1 unchanged attribute hidden)
    }
https://github.com/airbytehq/airbyte/discussions/63319 I basically want to add a globally unique UUID to all rows from all streams of a given sync... then i can just find the record with the
MAX(__airbyte_extracted_at)_
get this globally unique value and find all the rows from the given sync... The metadata sync_id feels potentially useful but It's also hard to rely on: • what if i ever have to smoke the whole install and reinstall/re-apply the terraform
k
You're correct that using
full_refresh_append
sync mode in Airbyte, especially when managed by Terraform, can make it challenging to identify which records belong to the "latest sync." This is because when Terraform deletes and recreates a connection, the
_airbyte_generation_id
is reset, breaking continuity for tracking generations across connection recreations. ### Key Points from Airbyte Documentation - _airbyte_generation_id: This field is incremented on every refresh or clear, but if the connection is deleted and recreated (as Terraform often does), the generation ID will start over from 0. This makes it unreliable for tracking across connection recreation events, as you observed. Each stream's generation is tracked independently, and the counter never decreases, but it does reset on recreation of the connection or stream [see: Data Generations FAQ](https://docs.airbyte.com/platform/next/operator-guides/refreshes#frequently-asked-questions-faq). - _airbyte_extracted_at: This timestamp is present on every row and can be used to find the most recent sync's records by looking for the maximum value. However, it is not a globally unique sync identifier, and if multiple streams are synced in parallel, the max value may not be the same across all streams. - sync_id in _airbyte_meta: Airbyte now stores a
sync_id
within the
_airbyte_meta
object column for certified destinations. This can help you identify which rows came from which sync job, but again, if you "smoke the whole install" and reapply everything, the continuity of
sync_id
may be lost, as it is tied to the Airbyte instance's state [see: Github Issue #4025](https://github.com/airbytehq/airbyte/issues/4025). ### Limitations and Workarounds - No globally unique sync UUID across all streams and all Airbyte installs: The knowledge sources do not mention a built-in, globally unique sync UUID that persists across Airbyte instance resets or Terraform-driven recreation of resources. - If you need a persistent, unique sync identifier: You would need to implement this outside of Airbyte, for example, by generating a UUID at the start of each sync (perhaps via an orchestrator or wrapper script) and injecting it into your data as a custom column during normalization or post-processing. ### Summary -
_airbyte_generation_id
is not reliable across connection recreation. -
_airbyte_extracted_at
can help, but is not a unique sync identifier. -
sync_id
in
_airbyte_meta
is helpful, but not persistent across full reinstall/reapply. - There is no built-in, persistent, globally unique sync UUID for all rows across all streams and Airbyte installs. If you need this level of tracking, you will need to implement a custom solution outside of Airbyte. The knowledge sources do not describe a built-in way to achieve this in the scenario you outlined. If you have further questions or want to discuss possible workarounds, let me know!
l
@kapa.ai how can i add the unique UUID after the airbyte sync if it's in the append table and i can't reliably identify which rows come from which run
k
A message from kapa.ai
Based on the knowledge sources, Airbyte does not provide a built-in, persistent, globally unique sync UUID that you can use to reliably tag all rows from a given sync, especially if connections are deleted and recreated (as with Terraform). The available metadata fields—such as
_airbyte_generation_id
,
_airbyte_extracted_at
, and
sync_id
in `_airbyte_meta`—are either reset on connection recreation or are not globally unique across all streams and syncs [see: Data Generations](https://docs.airbyte.com/platform/next/operator-guides/refreshes#data-generations), [Github Issue #4025](https://github.com/airbytehq/airbyte/issues/4025). Therefore, there is no built-in way in Airbyte to add a unique UUID to all rows from a specific sync after the sync has completed if you cannot reliably identify which rows belong to which run. The knowledge sources do not describe a method for post-hoc tagging of rows in append tables with a unique sync identifier under these circumstances. If you need this functionality, you would need to implement a custom solution outside of Airbyte, such as: - Maintaining your own sync tracking table and joining on timestamps or other metadata. - Using an external orchestrator to generate and inject a UUID at sync time. But to reiterate, the knowledge sources do not provide a built-in or recommended Airbyte-native solution for this scenario.
w
following... the fact that airbyte TF decides to delete/recreate is putting me off of migrating the custom YAML code into Terraform. It destroys the connection state/cursor making it hard to have incremental refreshes.
l
yup that is my experience as well
sadparrot 1
i had to go some extra lengths to add identifiers (my orchestrator creates a custom UUID before each run and sets the variable, then triggers airbyte) not a fun tradeoff
👀 1