.agents/skills/tinybird-cli-guidelines/rules/data-operations.md
Operations for updating and removing data from Data Sources.
Delete rows matching a SQL condition:
tb datasource delete events --sql-condition "toDate(date) >= '2019-11-01' AND toDate(date) <= '2019-11-30'"
--wait to block until completeDelete all rows from a Data Source:
tb datasource truncate events
Use --cascade to also truncate dependent Data Sources attached via Materialized Views.
Replace only data matching a condition:
tb datasource replace events data.csv --sql-condition "toDate(date) >= '2019-11-01' AND toDate(date) <= '2019-11-30'"
⚠️ Critical: Never replace data in partitions where you are actively ingesting. You may lose data inserted during the operation.
Rules:
If your Data Source uses ENGINE_PARTITION_KEY "country" and you run:
tb datasource replace events data.csv --sql-condition "status='active'"
This will not work as expected—the replace process uses payload rows to identify partitions. Always match the partition key.
Replace entire Data Source contents (no --sql-condition):
tb datasource replace events data.csv
⚠️ Critical: Do not run while actively ingesting—you may lose data.