<@U04S8PLJWMT> What is the exact SQL sort conditio...
# replication-ask-ai
w
@kapa.ai What is the exact SQL sort condition that the current version of Airbyte uses to determine transaction order when delivering Postgres CDC records to Snowflake?
k
The knowledge sources do not contain enough information to answer this query with confidence. Specifically, none of the provided documents describe the exact SQL sort/ordering condition used when processing Postgres CDC records destined for Snowflake. What the knowledge sources do show is the sort condition used in Airbyte's normalization layer (SCD Type 2 model) for ordering records generally (not Snowflake-CDC-specific):
Copy code
ORDER BY
    <cursor_field> IS NULL ASC,
    <cursor_field> DESC,
    _airbyte_emitted_at DESC
This is used in the
lag()
and
row_number()
window functions to determine
_airbyte_end_at
and
_airbyte_active_row
in the SCD table. [BigQuery SQL optimization; incremental sync tutorial] For CDC sources, Airbyte adds metadata columns like
_ab_cdc_updated_at
and
_ab_cdc_deleted_at
, and these are factored into the normalization SQL via
cdc_updated_at_order
and
cdc_active_row
variables in the SCD model. [CDC docs] However, the exact SQL expression for those CDC-specific ordering variables is not included in the provided knowledge sources. For the precise, up-to-date SQL used for Postgres CDC → Snowflake ordering, I'd recommend checking the Airbyte source code directly, particularly the normalization templates in stream_processor.py and the Snowflake destination connector. 👍 0 button 👎 0 button â„šī¸ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.