Can Fivetran Run Post-Sync SQL Automatically?
Question
How can I automatically run a PostgreSQL function, such as CALL schema.function_name(), or arbitrary SQL after my connection sync completes? If Fivetran doesn't support this, what is the recommended way to trigger downstream processes immediately after a sync?
Environment
Destination: PostgreSQL
Answer
No, Fivetran does not support running arbitrary SQL in your destination database as part of a connection's post-sync lifecycle. This means there is no built-in post-sync SQL hook for calling a PostgreSQL function or running custom SQL after a sync. To trigger downstream processes after a sync, you have two options.
Fivetran transformations
Use Fivetran Transformations, especially with dbt Core, to run SQL jobs after new data lands in your destination. Transformations run as soon as new data lands in your destination after each connection sync. With dbt, you can use hooks or operations to run custom SQL, including function calls, as part of your transformation workflow.
External orchestration with webhooks
Subscribe to the Fivetran sync_end webhooks event. When the payload indicates that the sync completed successfully, trigger an external orchestration tool, such as Airflow, Prefect, or a serverless function, to run the downstream SQL or PostgreSQL function.