Hello folks - I'm working on a eCommerce dataset -...
# ask-ai
v
Hello folks - I'm working on a eCommerce dataset - on airbyte OSS deployed on EC2, I'm trying to connect MYSQL as source to my Clickhouse destination. My use case is simple - to migrate last 30 days sale data from orders table based on delivery date. How can I filter this data and only migrate what I want. . Note: I cannot see replication start date when creating the source.
k
Currently, Airbyte's MySQL source connector does not natively support filtering data by a custom WHERE clause (such as "last 30 days based on delivery date") during syncs. The platform generally follows the ELT paradigm, meaning it extracts all data from the source and then transforms it in the destination. This can be inefficient if you only want a subset of the data, as you’ve described. Workarounds based on current capabilities: 1. Create a View in MySQL: The recommended approach is to create a view in your MySQL database that only includes the last 30 days of sales data from your orders table. You can then configure Airbyte to sync from this view instead of the full table. This way, only the filtered data is extracted and migrated to ClickHouse. This method is suggested in multiple community discussions and is the most straightforward workaround for your use case [Forum: MySQL CDC to Kafka - capturing only recent changes](https://discuss.airbyte.io/t/1584) [Forum: Using dbt transformation to aggregate data during a sync?](https://discuss.airbyte.io/t/3455). 2. No Built-in WHERE Clause Support: There is an open feature request to allow users to specify a WHERE clause or a start date for JDBC sources, but as of now, this is not supported out of the box [Github Issue: Pass a where clause on 'Full Append' or 'Full Overwrite'](https://github.com/airbytehq/airbyte/issues/21508) [Github Issue: Source JDBC: Support
start_date
configuration field](https://github.com/airbytehq/airbyte/issues/13998). 3. Incremental Syncs: If your table has a suitable cursor field (like an updated_at or delivery_date column), you could use Airbyte’s incremental sync mode. However, this requires that the connector supports filtering by that field, and for MySQL, this is typically only available for CDC (Change Data Capture) mode, which may not fit your use case if you only want the last 30 days and not all changes since the beginning of the table [Incremental sync documentation](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync). Summary: To filter and migrate only the last 30 days of sales data from MySQL to ClickHouse, create a view in MySQL that selects only the relevant rows, and then configure Airbyte to sync from that view. There is currently no built-in way to specify a WHERE clause or dynamic date filter directly in the Airbyte UI for the MySQL source. If you need further automation (e.g., always "last 30 days" relative to the sync date), you can define your view with a dynamic condition like:
Copy code
sql CREATE OR REPLACE VIEW recent_orders AS SELECT * FROM orders WHERE delivery_date >= CURDATE() - INTERVAL 30 DAY;
Then, point Airbyte to the
recent_orders
view as your source. If you need more advanced filtering features, you may want to subscribe to the related GitHub issues for updates on future support.
v
@kapa.ai Does using DBT with airbyte help for my use case in anyway?
k
A message from kapa.ai
Using dbt with Airbyte can help you transform and aggregate data after it has been loaded into your destination (ClickHouse), but it does not help filter or limit the data extracted from your MySQL source before it is loaded. Airbyte follows the ELT paradigm: it first extracts and loads all data from the source, and then dbt can be used to transform that data in the destination. This means you would still be transferring all the data from MySQL to ClickHouse, and only then could you use dbt to filter for the last 30 days of sales data or perform further transformations. This approach is confirmed in community discussions, where it is noted that dbt transformations run on the destination data, not at the source extraction stage. If you only want to migrate a subset of data (like the last 30 days), you would still need to filter at the source (e.g., by using a view in MySQL), as dbt cannot reduce the amount of data transferred by Airbyte from the source to the destination. dbt is useful for cleaning, aggregating, or enriching data after it has landed in your destination, but not for limiting what is extracted from the source in the first place [Using dbt transformation to aggregate data during a sync?](https://discuss.airbyte.io/t/3455). In summary: dbt with Airbyte helps with post-load transformations, not with filtering data at extraction. For your use case, it does not help reduce the data volume transferred from MySQL to ClickHouse, but it can help process or aggregate the data after it arrives in ClickHouse.
v
@kapa.ai I only have select access on mysql and do not have special accesses like replicate or create etc. Is this the reason I can't see replication start date while configuring MYSQL source? If not this - then why can't I see the replication start date?
k
A message from kapa.ai
The reason you cannot see the "replication start date" when configuring the MySQL source in Airbyte is not directly related to your lack of special privileges (like REPLICATION or CREATE). Instead, it is because the MySQL source connector in Airbyte does not natively expose a "replication start date" field in its configuration UI. This is a known limitation: - There is no built-in option in the Airbyte MySQL source connector to specify a "replication start date" or to filter data by date at extraction time. This feature has been requested by users, but as of now, it is not available in the connector’s configuration interface [Github Issue: Source JDBC: Support
start_date
configuration field](https://github.com/airbytehq/airbyte/issues/13998). Your limited permissions (SELECT only) mean you cannot use CDC (Change Data Capture) mode, which requires additional privileges like REPLICATION SLAVE and REPLICATION CLIENT. However, even with full privileges, the "replication start date" field would still not appear, because it is not a feature currently supported by the connector. Summary: You cannot see the "replication start date" because the Airbyte MySQL source connector does not support this option, not because of your user permissions. If you need to filter data at extraction, you would need to use a view or wait for this feature to be implemented in Airbyte.
v
1. @kapa.ai got it. What all SQL level permissions & other prerequisites will I need for my use case i.e Migrate data & keep refreshing new row inserts/row updates
k
A message from kapa.ai
To migrate data from MySQL and keep refreshing with new row inserts/updates (i.e., perform incremental syncs), the required SQL permissions and prerequisites depend on the sync mode you want to use: --- ### 1. For Standard (Non-CDC) Incremental Syncs If you are using Airbyte's standard incremental sync (not CDC), you only need SELECT permission on the relevant tables. This allows Airbyte to read data and track changes using a cursor field (like an updated_at column). Prerequisites: - SELECT permission on the source tables. - A suitable cursor field (e.g., a timestamp or incrementing ID) in your table to track new/updated rows. --- ### 2. For CDC (Change Data Capture) Incremental Syncs If you want to use CDC (which captures inserts, updates, and deletes in near real-time), you need additional permissions because Airbyte (via Debezium) reads the MySQL binary logs. Required MySQL permissions for CDC:
Copy code
sql GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'airbyte'@'%';
- SELECT: Read data from tables. - RELOAD: Required for Debezium to take consistent snapshots. - SHOW DATABASES: Allows listing databases. - REPLICATION SLAVE and REPLICATION CLIENT: Required to read the binary logs for CDC. Other prerequisites: - Binary logging must be enabled on your MySQL server. - The tables you want to replicate should have a primary key for CDC incremental syncs to work properly. - Airbyte user must have access to the relevant database and tables. Reference: [MySQL CDC: Build an ELT pipeline from MySQL Database](https://airbyte.com/tutorials/mysql-change-data-capture-cdc#step-2) [MySQL Source Troubleshooting & CDC Requirements](https://docs.airbyte.com/integrations/sources/mysql/mysql-troubleshooting) [Forum: Privilleges required for the MySQL connector (CDC replication)](https://discuss.airbyte.io/t/1671) --- Summary Table: | Sync Mode | Minimum Permissions Needed | Other Prerequisites | |-------------------|-----------------------------------------------------------|------------------------------------| | Standard Incremental | SELECT | Cursor field in table | | CDC Incremental | SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT | Binary logging enabled, primary key | --- If you only have SELECT access, you can use standard incremental sync (with a cursor field), but not CDC. For CDC, you need the additional permissions listed above. If you need to migrate deletes as well, CDC is required. Let me know if you need details for a specific sync mode or further clarification!