Iceberg: support add_files and replace_files (register existing data files into a table)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
The feature adds ALTER TABLE t EXECUTE add_files/replace_files for Iceberg tables. Start from the EXECUTE statement handling in ClickHouse's SQL parser and the Iceberg engine integration. Done means the commands register existing files with correct statistics and return metric rows.
Written by the indexing model from the issue text.
Description
Describe the problem
There is no way to make an Iceberg table aware of data files that already exist in object storage. Every row has to be written through the sink of this engine, so a pipeline that produces Parquet files by another route (a clickhouse local run, file() output, another engine, a copy from a staging bucket) can not promote them into a table without re-reading and re-writing every byte.
The Iceberg answer to this is add_files / rewrite_files: register existing files in one snapshot, computing their statistics and partition values from the files themselves. Without it, every such pipeline needs an external Iceberg library just to publish its output.
Proposal
An ALTER TABLE ... EXECUTE entry point in the shape iceberg-java and pyiceberg use:
ALTER TABLE t EXECUTE add_files(paths [, check_duplicate_files = 1] [, allow_missing_columns = 0])
ALTER TABLE t EXECUTE replace_files(remove = [...] [, add = [...] ] [, relocate = 0] [, allow_missing_columns = 0])
Semantics:
pathsis a path or an array of paths; a path ending in/means every*.parquetbelow it (hidden path components, starting with., skipped). A relative path is relative to the table root. Each file is read once in this server to derive its record count, column sizes, value/null/NaN counts, bounds, and its partition tuple.- The partition tuple must resolve to a single partition of the current default spec. A file that spans partitions is not registered; the error names the file and the offending column.
add_fileswrites one snapshot with operationappend. Duplicate detection (check_duplicate_files) compares against the files already live in the current snapshot.replace_filesremoves the listed live files and adds the listed new ones in one snapshot with operationoverwrite(ordeletewhen there is noadd). Withrelocate = 1the i-th added file is a byte-identical copy of the i-th removed one (same size is verified): its manifest entry is copied with only the path changed, and the file is not read - which makes a storage-tier move a metadata operation instead of a data copy.allow_missing_columnscontrols whether a file that lacks a column present in the table schema is registered (values then come from the column default) or refused.- On a v3 table every registered file is assigned a
first_row_id, so_row_idworks for rows that were never written by this engine. - The statement returns one row per metric (
metric_name,metric_value) so the caller can see how many files and rows were registered.
Why EXECUTE rather than a new statement
The command operates on an external catalog object and reports metrics, which is what the EXECUTE surface is for. It also keeps the semantics of the operation separate from a plain INSERT, which has its own commit path.
Notes
- Statistics have to be computed with the
write.metadata.metrics.*of the table properties, or the manifest entry of a promoted file disagrees with a natively written one and pruning behaves differently for the two. replace_fileswithrelocate = 1must verify the size, not just trust the caller: a manifest entry whosefile_size_in_bytesis wrong reads the next file short.- The duplicate check is on the full path resolved against the table root, not the argument as typed, or the same file registers twice under two spellings.
- Registering a file that is still being written by another process is not detectable here; that is the contract of the caller, but the error text for a truncated file should say so rather than reporting a parse failure.
- Dominant language
- C++
- Stars
- 50.6k
- Forks
- 9.2k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 524
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/ClickHouse
-
ai_p3 comp-promql
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
ClickHouse/ClickHouse#128448 ·
Maintainers usually reply within 1 day
-
ai_p1 comp-view external potential bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ClickHouse/ClickHouse#128410 ·
Maintainers usually reply within 1 day
-
ai_p3 comp-sql-syntax
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ClickHouse/ClickHouse#128399 · 2 comments ·
Maintainers usually reply within 1 day
-
comp-documentation external
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ClickHouse/ClickHouse#128350 ·
Maintainers usually reply within 1 day
-
Paimon `DATE` is read as `Date` instead of `Date32`: dates before 1970 or after 2149 fail with VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPEPossibly taken @groeneai claimed this 2 days ago. Openai_p2 bug comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ClickHouse/ClickHouse#128306 · 3 comments ·
Maintainers usually reply within 1 day
All issues in ClickHouse/ClickHouse
Similar issues
-
artifact:simulation-scenario domain:physics good first issue help wanted role:validation testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
moneymanagerex/moneymanagerex#8600 · 1 comment ·
Maintainers usually reply within 4 days
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
NVIDIA/accelerated-computing-hub#294 ·
Maintainers usually reply within 4 days