Hi all,
We run the same EXPORT DATA statement regularly to export a 30-minute window (about 2,500 rows) from a BigQuery table to CSV files in GCS. Some runs produce 1 or 2 files. Some runs produce more than 250 files, and 99% of them contain only the header row.
Example command I ran:
EXPORT DATA OPTIONS (
uri = ‘gs:////-*.csv’,
format = ‘CSV’,
overwrite = true,
header = true
) AS
SELECT *
FROM ..
FOR SYSTEM_TIME AS OF TIMESTAMP(‘<read_ts>’)
WHERE timestamp <= TIMESTAMP(‘’)
AND timestamp > TIMESTAMP_SUB(TIMESTAMP(‘’), INTERVAL 30 MINUTE);
Example: two runs of the same SQL on the same table, 8 minutes apart.
- Run A: 266 files, 265 of them header-only. parallelInputs 266, totalSlotMs 131,524.
- Run B: 2 files, none header-only. parallelInputs 267, totalSlotMs 1,752.
The SQL, job configuration and query plan (a single “S00: Output” stage) are the same in both runs. In the bad runs, fileCount usually equals parallelInputs, and totalSlotMs is much higher. Each run writes to a new prefix, so these aren’t leftover files from earlier exports.
Questions:
- Is it expected that EXPORT DATA writes a header-only file for each parallel input that has no matching rows?
- Why does the same statement sometimes produce 2 files and sometimes 266?
- Is there a supported way to avoid the empty files?
Thanks!