<@U04S8PLJWMT> I am wondering if this format looks...
# ask-ai
d
@kapa.ai I am wondering if this format looks OK for the configurations, specifically the cursor_field which I just added.
Copy code
resource "airbyte_connection" "postgres_to_snowflake" {
  source_id            = airbyte_source_postgres.postgres_source.source_id
  destination_id       = airbyte_destination_snowflake.snowflake_destination.destination_id
  status               = var.airbyte_connector_enabled ? "active" : "inactive"
  namespace_definition = "custom_format"
  namespace_format     = upper(var.airbyte_connector_destination_schema)
  schedule = {
    schedule_type   = "cron"
    cron_expression = "0 0/10 * * * ? UTC"
  }
  configurations = {
    streams = flatten([
      for schema in var.schemas : [
        for table in schema.tables : {
          name         = table.name
          sync_mode    = coalesce(table.sync_mode, "incremental_append")
          primary_key  = lookup(table, "primary_key", null)
          cursor_field = lookup(table, "cursor_field", null)
        }
      ]
    ])
  }
}
k
Your configuration format for the Airbyte connection, especially the use of the
cursor_field
, generally aligns with Airbyte's documented requirements for incremental syncs. Here are some key points based on the knowledge sources: - The
cursor_field
is required when
sync_mode
is set to
incremental
. It should be an array of strings representing the path to the field used to determine if a record is new or updated since the last sync. If the stream has
source_defined_cursor
set to
true
, the
cursor_field
in your configuration will be ignored. If a
default_cursor_field
is defined in the stream, your
cursor_field
will override it if set. If neither is defined, you must provide a
cursor_field
in your configuration, which you are doing via
lookup(table, "cursor_field", null)
[[ConfiguredAirbyteStream](https://docs.airbyte.com/platform/understanding-airbyte/airbyte-protocol#configuredairbytestream)]. - The value of
cursor_field
should be an array (e.g.,
["updated_at"]
), not just a string. Ensure that your
table.cursor_field
variable is structured accordingly. - For incremental syncs to work correctly, the chosen cursor field should be monotonically increasing, not updated after creation, and ideally indexed for performance. Examples include timestamp columns like
created_at
or
updated_at
, or auto-incrementing IDs [[Snowflake Incremental Sync](https://docs.airbyte.com/integrations/sources/snowflake#incremental-sync)]. - The rest of your configuration (e.g.,
primary_key
,
sync_mode
) also matches the expected structure for Airbyte connections. Example of a valid stream configuration:
Copy code
json {   "name": "my_table",   "sync_mode": "incremental",   "primary_key": [["id"]],   "cursor_field": ["updated_at"] }
Make sure that your
cursor_field
is provided as an array of strings, even if it's just one field. Summary: Your format is correct as long as
cursor_field
is an array of strings and the field exists in your source schema. Double-check that your variables (
table.cursor_field
) are structured this way. If you follow these guidelines, your configuration should work as expected [[ConfiguredAirbyteStream](https://docs.airbyte.com/platform/understanding-airbyte/airbyte-protocol#configuredairbytestream)]. If you need to support nested fields, the array should represent the path (e.g.,
["metadata", "updated_at"]
) [[Cursor](https://docs.airbyte.com/platform/understanding-airbyte/airbyte-protocol#cursor)]. If you have further questions about the structure of the variables or need a more concrete example, please provide a sample of your
table
variable structure.
d
Copy code
# module.airbyte_connector["partnerships_marketplace_airbyte_connector"].airbyte_connection.postgres_to_snowflake will be updated in-place
  ~ resource "airbyte_connection" "postgres_to_snowflake" {
      ~ configurations                       = {
          ~ streams = [
              - {
                  - cursor_field    = [
                      - "_ab_cdc_lsn",
                    ] -> null
                  - mappers         = [] -> null
                  - name            = "application_connection" -> null
                  - primary_key     = [
                      - [
                          - "id",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "full_refresh_append" -> null
                },
              - {
                  - cursor_field    = [
                      - "_ab_cdc_lsn",
                    ] -> null
                  - mappers         = [] -> null
                  - name            = "partner_application_partner_product" -> null
                  - primary_key     = [
                      - [
                          - "application_id",
                        ],
                      - [
                          - "partner_product_id",
                        ],
                    ] -> null
                  - selected_fields = [] -> null
                  - sync_mode       = "incremental_append" -> null
                },
              + {
                  + cursor_field    = [
                      + "_ab_cdc_lsn",
                    ]
                  + mappers         = []
                  + name            = "application_connection"
                  + primary_key     = [
                      + [
                          + "id",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "incremental_append"
                },
              + {
                  + cursor_field    = [
                      + "_ab_cdc_lsn",
                    ]
                  + mappers         = []
                  + name            = "partner_application_partner_product"
                  + primary_key     = [
                      + [
                          + "application_id",
                          + "partner_product_id",
                        ],
                    ]
                  + selected_fields = []
                  + sync_mode       = "incremental_append"
                },
                # (5 unchanged elements hidden)
            ]
        }
        name                                 = "staging-partnerships-marketplace <> staging-snowflake-analytics-partnerships-marketplace"
        tags                                 = []
        # (12 unchanged attributes hidden)
    }
besides setting it in the connection what else do i need to do? it's using the source cursor
what is
scan_changes_with_user_defined_cursor