Skip to content

Reject compression_method argument for data lake engines - #105667

Open
groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-105644-reject-compression-method-for-datalake-engines
Open

groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-105644-reject-compression-method-for-datalake-engines

Conversation

@groeneai

@groeneai groeneai commented May 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #105644

Data lake engines (Iceberg, DeltaLake, Hudi, Paimon) accept a compression_method argument, but the on-disk file format (Parquet/ORC/Avro) already has its own internal codec. For IcebergLocal/IcebergS3/etc. the write path goes through MultipleFileWriter::startNewFile, which never wraps the buffer with wrapWriteBufferWithCompressionMethod, so the user's compression='lzma' is silently dropped and the on-disk file is raw Parquet. The read path in StorageObjectStorageSource still calls chooseCompressionMethod(filename, configuration->compression_method), which with hint 'lzma' ignores the .parquet extension and returns CompressionMethod::Xz, then wraps the read buffer with LZMAInflatingReadBuffer. The decoder sees raw Parquet bytes and fails with LZMA_FORMAT_ERROR.

For DeltaLake/Hudi/Paimon the write path uses StorageObjectStorageSink, which does honor the outer codec, so the file round-trips inside ClickHouse, but the produced LZMA-wrapped Parquet is unreadable by external engines (Spark, Trino, etc.). Same class of silent corruption from an interoperability point of view.

This change rejects explicit compression_method / compression values other than auto (case-insensitive) or an empty string at fresh-definition time for any data lake configuration (Iceberg, DeltaLake, Hudi, Paimon), with a clear error pointing at the format-specific codec setting. Users who need to control file compression should use the format-specific settings such as output_format_parquet_compression_method. The default value pass-through is unchanged: the rejection only fires when the user explicitly supplied the argument, so unmodified CREATE TABLE statements continue to work.

The rejection is gated on LoadingStrictnessLevel == CREATE, so it fires only for a fresh definition: a CREATE TABLE (also CREATE TABLE ... AS f(...) with a data lake table function), or a data lake table function in a query. Every other mode replays a definition that was already accepted when the table was created, and is deliberately exempt as a compatibility path so pre-fix tables still load after an upgrade: every ATTACH form (short-syntax ATTACH TABLE name, full-definition ATTACH TABLE name FROM '<path>' (cols) ENGINE = ..., and the server-startup replay paths FORCE_ATTACH / FORCE_RESTORE), and SECONDARY_CREATE, which covers both RESTORE TABLE and the replay of the stored CREATE TABLE text by DatabaseReplicated::recoverLostReplica (so a Replicated database created before this validation landed still recovers on an upgraded replica). Note that this includes a user-supplied full-definition ATTACH, which can therefore still persist a definition carrying compression_method; per review, the gate is intentionally kept simple rather than special-casing the ATTACH shapes. A fresh CREATE in a Replicated database is still rejected, because the initiator runs it as an initial query and therefore with mode == CREATE.

The tables of a catalog-backed database (DataLakeCatalog, including the Glue catalog) derive their engine arguments verbatim from the positional arguments of the CREATE DATABASE query, so a compression_method or unsupported format there follows the same rule. The database passes CREATE to the per-table validation when the user supplies the database definition - CREATE DATABASE or a full-definition ATTACH DATABASE ... ENGINE = ... (the definition is validated lazily, on first use, like the rest of this engine's configuration) - and ATTACH when its definition is replayed - server startup, a short ATTACH DATABASE db, or RESTORE DATABASE - so a database created before this validation landed keeps working after an upgrade. Covered by the new integration test test_database_iceberg/test.py::test_compression_argument_in_database_definition.

Reproducer (no longer accepted after this patch):

CREATE TABLE t0 (c0 Int)
ENGINE = IcebergLocal('/var/lib/clickhouse/user_files/lakehouses/t0', 'Parquet', 'lzma');
-- Code: 36. DB::Exception: The `compression_method` argument is not
-- supported by data lake engines. ...

This change also rejects an explicit format that the lake cannot store its data files in, reported on this pull request while fuzzing data lakes. It is the same failure mode as the compression_method one: INSERT INTO TABLE FUNCTION deltaLakeLocal(..., format = 'RowBinary') is accepted, writes the file, and commits it into the Delta log as an ordinary data file, after which every reader - ClickHouse included - parses it as Parquet, because the Delta log records no per-file format. The table is corrupted for good. The read side is worse still: opening an untouched, all-Parquet Delta table with format = 'RowBinary' returns garbage rows and no error at all.

The accepted set is per engine, exposed through the new getSupportedDataLakeFormats, because the engines genuinely differ:

Engine Accepted data file formats Why
DeltaLake Parquet The Delta log records no per-file format, so the reader always falls back to the configured one.
Iceberg Parquet, ORC, Avro, Vortex The format is recorded per data file in the manifest and honoured on read, so the three formats of the specification round-trip, and so does Vortex.
Paimon Parquet, ORC, Avro The data file formats of the Paimon specification.
Hudi Parquet, ORC format selects the extension of the base files that are listed, and Hudi base files are columnar.

The check reuses the exemptions of the compression_method gate, so a table persisted before this change still attaches, and it never fires for the auto default, which is resolved to the lake's own default afterwards.

Reproducer (no longer accepted after this patch):

CREATE TABLE t0 (c0 Int32) ENGINE = DeltaLakeLocal(local, path = '/var/lib/clickhouse/user_files/lakehouses/t0/', format = 'RowBinary');
-- Code: 36. DB::Exception: The `RowBinary` format is not supported by the
-- DeltaLakeLocal data lake engine, which stores its data files as Parquet. ...

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Reject explicit compression_method / compression values other than auto (case-insensitive) or an empty string for data lake engines (Iceberg, DeltaLake, Hudi, Paimon) at fresh-definition time. The outer compression codec was silently dropped on the Iceberg write path while still applied on read, producing files the engine could not read back. For other data lake formats it produced non-standard files unreadable by external engines. Users who need to control file compression should use the format-specific settings such as output_format_parquet_compression_method. Also reject an explicit format that the lake cannot store its data files in (Parquet for DeltaLake; Parquet, ORC, Avro or Vortex for Iceberg; Parquet, ORC or Avro for Paimon; Parquet or ORC for Hudi), which corrupted the table on write and silently returned garbage rows on read. Pre-existing tables persisted before this validation landed still load via ATTACH, server startup, RESTORE, and Replicated-database replica recovery.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Workflow [PR]
Sync PR [sync-upstream/pr/105667]

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (session cron:clickhouse-ci-task-worker:20260522-164500)

a) Deterministic repro? Yes. CREATE TABLE t (c0 Int) ENGINE = IcebergLocal('path', 'Parquet', 'lzma'); INSERT VALUES (1); SELECT *; deterministically fails with LZMA_STREAM_DECODER_FAILED (Code 554) on master. Reproduced locally twice (positional and named-collection forms) on the workspace debug build before the fix.

b) Root cause explained? Yes. Iceberg's write path (MultipleFileWriter::startNewFile) never wraps the buffer with wrapWriteBufferWithCompressionMethod, so the user's compression='lzma' is silently dropped and the on-disk file is raw Parquet. The read path in StorageObjectStorageSource::createReader (around line 769) still passes configuration->compression_method to chooseCompressionMethod, which with hint 'lzma' skips the .parquet extension and returns CompressionMethod::Xz, wrapping the read buffer in LZMAInflatingReadBuffer. The decoder then sees raw Parquet bytes and throws LZMA_FORMAT_ERROR.

c) Fix matches root cause? Yes. Reject any explicit non-default compression_method for data lake configurations at CREATE TIME. This eliminates the write/read inconsistency rather than papering over a symptom (e.g. teaching the write path to wrap too, which would only move the breakage to external readers like Spark/Trino).

d) Test intent / new tests added? Yes, new test 04274_105644_lzma_compression_rejected_for_datalake.sh covers: (1) compression='lzma' rejected with BAD_ARGUMENTS, (2) compression='gzip' rejected, (3) default succeeds with INSERT+SELECT round-trip, (4) explicit 'none' succeeds, (5) explicit 'auto' succeeds.

e) Both directions demonstrated? Yes. Before fix: bug reproduced with both positional (IcebergLocal('path', 'Parquet', 'lzma')) and named-collection forms. After fix: BAD_ARGUMENTS at CREATE TIME for lzma/gzip; default/none/auto all work. Local test produces the expected reference output.

f) Fix is general, not a narrow patch? Yes. The check sits in StorageObjectStorageConfiguration::initialize, the single chokepoint that covers all data lake variants: IcebergLocal/IcebergS3/IcebergAzure/IcebergHDFS, DeltaLakeS3/DeltaLakeAzure/DeltaLakeLocal, HudiS3, PaimonS3/PaimonAzure/PaimonHDFS/PaimonLocal. The asymmetric DeltaLake/Hudi/Paimon write path (which does honor the outer codec) is also covered by the same gate, preventing the silent external-reader-breaking corruption.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @PedroTadim @alesapin @scanhex12 @Michicosun could you review? This implements the CREATE-TIME rejection for the silent LZMA/data-lake corruption from #105644. It also covers DeltaLake/Hudi/Paimon (where the outer codec is applied on write but produces files external engines can't read).

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label May 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2f5dfa2]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/can_be_merged.py --review-threads FAIL

AI Review

Summary

Reviewed #105667 at 2f5dfa27edc29ec1492aafaf09ff6ed37ef2d47c. The change rejects unsupported outer compression and data-file formats for fresh data lake definitions while preserving the documented replay exemptions. One previously reported Major remains: catalog table creation commits remotely before the new validation can reject it. No new inline findings were added.

Findings

⚠️ Majors

  • DatabaseDataLake.cpp:1459–1465 — Validate inherited arguments before committing catalog creation. A fresh REST database using DataLakeCatalog(url, key, secret, 'Parquet', 'none') accepts its database definition. A subsequent CREATE TABLE with an argumentless IcebergS3 engine calls createTableAtDefaultLocation at line 1285, then tryGetTableImpl at line 1288, which reaches this validation and throws BAD_ARGUMENTS. The REST request uses stage-create = false, so the failed statement leaves a committed remote table. Retrying finds the existing table; DROP TABLE through this database also reaches the rejecting validation. Validate the inherited arguments before the external create, or stage the creation until validation succeeds. Existing unresolved inline finding; still present in the current code, so no duplicate comment was posted.
Tests
  • ⚠️ Extend the existing REST catalog integration coverage with a rejected CREATE TABLE using inherited compression arguments, and assert directly through the catalog that no table was created. The current database-definition test exercises reads and replay, not this creation failure. This review verified the failure through source tracing; no local build or runtime tests were run.
Final Verdict

Status: ⚠️ Request changes

Move validation before the remote catalog commit (or make creation transactional) and add the focused regression test above.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 22, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 26, 2026
The validation check is case-insensitive (it lowercases the input before
comparing to "auto"/"none"), but the validated value was not stored back
into configuration_to_initialize.compression_method. Downstream callers
of chooseCompressionMethod in IO/CompressionMethod.cpp compare the hint
case-sensitively at the auto/none fallback path, so inputs like AUTO or
None would pass this CREATE TIME check yet later throw
"Unknown compression method 'AUTO'" from read/write paths
(ReadBufferIterator, StorageObjectStorageSink, StorageObjectStorageSource).

Assign compression_method_lower back after validation so the stored value
is always one of: empty, "auto", "none". This keeps the user-facing
acceptance case-insensitive while ensuring downstream paths see only the
canonical lowercase form that chooseCompressionMethod handles.

The stateless regression test 04274 is extended with two new cases that
create data lake tables with `AUTO` and `None` and then run a query against
them.

Addresses inline review on ClickHouse#105667
from clickhouse-gh[bot] / @PedroTadim.
@alesapin alesapin self-assigned this May 28, 2026

@alesapin alesapin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai, just check that LoadingStrictnessLevel that it's less than ATTACH.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 28, 2026
Per @alesapin's review on ClickHouse#105667: scope the `compression_method` rejection
to fresh `CREATE` mode so a server upgrade does not lock users out of
tables whose metadata already persists a non-default value.

`StorageObjectStorageConfiguration::initialize` now takes a
`LoadingStrictnessLevel mode` parameter. The validation only throws when
`mode < LoadingStrictnessLevel::ATTACH`, matching the pattern used by
sibling storages (`Utils.cpp:306`, `StorageKafkaUtils.cpp:278` etc.). The
case canonicalization at the end of the block still runs unconditionally
so existing tables that happened to persist `AUTO` / `None` benefit from
the lowercase normalization on the read/write path too.

The two register call sites that have a real `args.mode`
(`registerStorageObjectStorage.cpp`, `registerQueueStorage.cpp`) now
forward it. The other two call sites (`TableFunctionObjectStorage`,
`DataLake` catalogs) keep the default `CREATE` and continue to reject
explicitly-typed bad values exactly as before; the synthetic ASTs they
build never carry a user-supplied `compression_method`, so the change is
behavior-preserving for them.

Regression test `04274_105644_lzma_compression_rejected_for_datalake.sh`
extended with two `ATTACH` scenarios (`lzma`, `gzip`) using the
deprecated `Ordinary` database engine so that the full-spec
`ATTACH TABLE name (cols) ENGINE = ...` form is accepted. Each
`grep -c` returns 0 with the gate in place; without the gate both return
1 (verified on a stripped binary).
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (commit 85d4f10, session cron:clickhouse-ci-task-worker:20260528-153000)

a) Deterministic repro? Yes. With the gate removed and the rest of the patch intact, ATTACH TABLE ord_test.t_lzma (c0 Int) ENGINE = IcebergLocal(..., 'Parquet', 'lzma') deterministically throws BAD_ARGUMENTS ("not supported by data lake engines"). With the gate, the same query succeeds.

b) Root cause explained? StorageObjectStorageConfiguration::initialize runs for every storage mode, called before createStorageObjectStorage inspects args.mode. The original validation therefore fires not only on fresh CREATE but also on server-restart ATTACH and explicit ATTACH TABLE, rejecting any pre-existing data lake table whose metadata persists a non-default compression_method. The fix adds mode < LoadingStrictnessLevel::ATTACH to the throw condition so the rejection applies only to fresh creation paths, matching the sibling pattern in Utils.cpp:306 and StorageKafkaUtils.cpp:278.

c) Fix matches root cause? Yes. The mode parameter is plumbed from the two register sites that have a real args.mode (registerStorageObjectStorage.cpp, registerQueueStorage.cpp). Table-function and catalog call sites keep the CREATE default; their synthetic ASTs never carry a user-supplied compression_method, so the change is behavior-preserving there.

d) Test intent preserved? Yes. Tests 1-7 still exercise CREATE-time rejection and canonicalization. Two ATTACH scenarios (lzma, gzip) were added that simulate post-upgrade metadata replay via the Ordinary engine (Atomic forbids the full-spec ATTACH TABLE name (cols) ENGINE = ... syntax).

e) Both directions demonstrated? Yes.

  • With gate removed (negative direction binary, 16:42 UTC): tests 8 and 9 produced 1 and 1 (rejection fires at ATTACH).
  • With gate restored (final binary, 16:58 UTC): tests 8 and 9 produced 0 and 0 (rejection skipped at ATTACH).
  • 10/10 stable passes against the new .reference with the fix.

f) Fix is general? Yes. The pattern matches the sibling CREATE-time gates already used elsewhere in src/Storages/. No symmetric code path was missed: the same initialize function is the single ingress for the compression_method validation on all four data lake engines (Iceberg, DeltaLake, Hudi, Paimon) and on the S3Queue/AzureQueue paths that share the configuration class.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@alesapin addressed in 85d4f10: StorageObjectStorageConfiguration::initialize now takes a LoadingStrictnessLevel mode parameter and the throw is gated on mode < LoadingStrictnessLevel::ATTACH, so pre-existing tables can still attach after upgrade while fresh CREATE statements remain rejected. Pattern matches the sibling CREATE-time gates in Utils.cpp:306 and StorageKafkaUtils.cpp:278. Pre-PR validation gate posted as a separate comment.

/// Gate the rejection on `mode < ATTACH` so existing tables created before this
/// validation landed can still attach after upgrade. The canonicalization below
/// runs unconditionally so attached tables also benefit from the lowercase fix.
if (mode < LoadingStrictnessLevel::ATTACH

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gates on every ATTACH path, including full-definition user queries like the new test's ATTACH TABLE ... ENGINE = IcebergLocal(..., 'lzma').

That still lets a user persist a new data-lake table with a non-default compression_method, so the broken read/write behavior remains reachable by replacing CREATE with ATTACH. Existing metadata does need to keep loading after upgrade, but the skip should be limited to metadata-replay paths, for example FORCE_ATTACH/FORCE_RESTORE and short ATTACH after the stored definition has been loaded. Full-definition ATTACH and ATTACH ... FROM should continue to run the new validation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid concern. The current gate (mode < LoadingStrictnessLevel::ATTACH)
follows the explicit CHANGES_REQUESTED directive on this PR ("just check
that LoadingStrictnessLevel that it's less than ATTACH"), which the previous
fixup commit 85d4f10f6db3 implemented. That gate covers CREATE and
SECONDARY_CREATE.

The bot's observation is correct that a user-supplied full-definition
ATTACH TABLE ... ENGINE = IcebergLocal(..., 'lzma') reaches this code with
mode == ATTACH and would slip past the rejection - which is exactly what
the new regression test exercises (and relies on, so that pre-existing tables
with the bad metadata can still be attached after upgrade).

Tightening to mode < LoadingStrictnessLevel::FORCE_ATTACH (reject CREATE,
SECONDARY_CREATE, and ATTACH; allow FORCE_ATTACH/FORCE_RESTORE) would
close the user-supplied-ATTACH hole, but only works if all server-startup
metadata-replay paths arrive with FORCE_ATTACH (not plain ATTACH). Happy
to flip the boundary if that's the preferred behavior - I'd like to confirm
with the reviewer whose CHANGES_REQUESTED set the current < ATTACH value
before changing it, since the trade-off is "user can deliberately ATTACH a
broken table" vs "all metadata-replay paths must use FORCE_ATTACH".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would keep the validation on user-supplied full-definition ATTACH and skip only existing-metadata replay or restore. Server startup loads tables with FORCE_ATTACH from loadMetadata.cpp, and RESTORE TABLE is already distinguished by is_restore_from_backup, so the boundary can be tightened to !isLoadingFromExistingMetadata(mode) && !is_restore_from_backup (or equivalently mode < LoadingStrictnessLevel::FORCE_ATTACH && !is_restore_from_backup) instead of mode < LoadingStrictnessLevel::ATTACH.

That still preserves old metadata loading after upgrade, but closes ATTACH TABLE ... ENGINE = IcebergLocal(..., 'lzma') as a fresh-definition bypass.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One correction to the concrete condition above: if short ATTACH TABLE t must also remain compatible for detached pre-upgrade metadata, mode alone is not enough because that path still uses LoadingStrictnessLevel::ATTACH after loading the stored query. In that case, please pass the ASTCreateQuery distinction through as well and skip only for args.query.attach_short_syntax, isLoadingFromExistingMetadata(args.mode), or args.is_restore_from_backup.

The path that should still be rejected is full-definition ATTACH TABLE ... ENGINE = ... / ATTACH ... FROM, where the user is supplying a fresh definition.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit 1876ef1821c. Plumbed args.query.attach_short_syntax through StorageObjectStorageConfiguration::initialize (and the parallel registerQueueStorage site) and tightened the gate to:

if (!is_attach_short_syntax
    && !isLoadingFromExistingMetadata(mode)
    && !is_restore_from_backup
    && configuration_to_initialize.compression_method_user_provided)
{
    throw ...;
}

The new predicate skips only the metadata-replay paths: short ATTACH TABLE name, FORCE_ATTACH (server startup loading from metadata/), FORCE_RESTORE, and RESTORE TABLE. Full-definition ATTACH TABLE name FROM '<path>' (cols) ENGINE = IcebergLocal(..., 'lzma') is rejected because the user is supplying a fresh definition.

Test 04274 gained case 9b covering ATTACH TABLE ... FROM '<path>' (cols) ENGINE = ... ('lzma') (the plain ATTACH TABLE name (cols) ENGINE = ... form is rejected up-front by the Atomic database engine, so the test uses the FROM '<path>' form which reaches the storage factory). Cases 8 and 9 (short ATTACH replay of pre-fix metadata) still pass. FORCE_ATTACH was verified manually by injecting 'lzma' into a saved .sql metadata file and restarting the server: the table loads cleanly with no BAD_ARGUMENTS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status update so this thread matches the shipped code: the tightened gate described above (commit 1876ef1821c, rejecting full-definition ATTACH) was later simplified away per the maintainer's explicit CHANGES_REQUESTED directive ("just check that LoadingStrictnessLevel that it's less than ATTACH"). The final gate is mode < LoadingStrictnessLevel::ATTACH plus the is_restore_from_backup guard, and the is_attach_short_syntax parameter was removed again. All ATTACH forms — including a user-supplied full-definition ATTACH TABLE ... ENGINE = ... — are deliberately exempt as a compatibility path; the code comment, test 9b, and the PR description state this explicitly rather than claiming the metadata was previously validated. Leaving the final call on that trade-off to the maintainers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵 Status update after bf0bf592d27: the gate moved from mode < LoadingStrictnessLevel::ATTACH to mode == LoadingStrictnessLevel::CREATE (to exempt SECONDARY_CREATE, see the sibling thread on the Replicated-database recovery path). This does not change the behaviour discussed here: every ATTACH form, including a user-supplied full-definition ATTACH TABLE ... ENGINE = ..., remains deliberately exempt as a compatibility path, per the maintainer's explicit CHANGES_REQUESTED directive to keep the gate simple. The code comment, the test comments, and the PR description all state this explicitly rather than claiming the metadata was previously validated. The final call on that trade-off is left to the maintainers.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 28, 2026
Per clickhouse-gh[bot] review on PR ClickHouse#105667: the prior ATTACH tests only
counted occurrences of the "not supported by data lake engines" rejection
string with `grep -c`. If `ATTACH` ever failed for any other reason (engine
init bug, metadata format change, syntax change), `grep -c` would still print
0 and the test would pass without ever observing the table.

After each `ATTACH`, also assert `EXISTS TABLE ${ORD_DB}.t_attach_*` is `1`,
proving the table was actually attached to the catalog. Local verification:
20/20 passes with the LoadingStrictnessLevel gate in place; the test FAILS
on both old (grep=2) and new (EXISTS=0) checks when the gate is removed,
so the new assertion catches the regression class the bot flagged.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate for 006ab12:

(a) Deterministic repro? Yes. With my new gate disabled (single line change locally,
build the binary, restart server), the 04274 test deterministically fails: lines 8-11
flip from 0,1,0,1 to 1,0,1,0 because each ATTACH is now rejected.

(b) Root cause explained? Yes. RESTORE TABLE reaches initialize with
mode == SECONDARY_CREATE (per
InterpreterCreateQuery::createTable and getLoadingStrictnessLevel(secondary=true)).
SECONDARY_CREATE < ATTACH, so the previous mode < ATTACH gate alone still rejected
restore. The new gate mode < ATTACH && !is_restore_from_backup lets restore proceed.

(c) Fix matches root cause? Yes. The plumbing follows the bot's suggestion verbatim:
forward args.is_restore_from_backup from StorageFactory::Arguments into
initialize. No alternative behaviors changed.

(d) Test intent preserved? / new tests added? Yes. The ATTACH section of 04274
was rewritten from a deprecated-Ordinary CREATE DATABASE construction (the source of
the flaky-check stderr warnings) to an Atomic-database
DETACH + on-disk-metadata sed rewrite + ATTACH cycle. It still asserts the
rejection error string is absent AND the table actually exists afterwards. Lines 8-11
of the reference are unchanged; the gate boundary being exercised
(mode == ATTACH vs mode < ATTACH) is identical.

(e) Both directions demonstrated? Yes.

  • Restored binary: 20/20 stable passes on tests/queries/0_stateless/04274_105644_lzma_compression_rejected_for_datalake.sh, empty stderr, diff to reference is empty.
  • Negative-verify binary (gate replaced with mode <= LoadingStrictnessLevel::ATTACH,
    rebuilt, server restarted): test fails with the expected line-8-through-11 flip.

(f) Fix is general, not a narrow patch? Yes.

  • Same gate applies to all 4 data lake formats (Iceberg, DeltaLake, Hudi, Paimon)
    because they all go through StorageObjectStorageConfiguration::initialize.
  • The new parameter is also forwarded by registerQueueStorage.cpp so the queue
    engines (S3Queue, AzureQueue) get the same treatment.
  • All other initialize call sites (TableFunctionObjectStorage, DatabaseDataLake,
    GlueCatalog) keep the is_restore_from_backup = false default; their synthetic
    ASTs never carry a user-supplied compression_method literal, so behavior is
    preserved.

CI run pending on commit 006ab12a45eb.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate for commit 3fee1c5 (session cron:clickhouse-ci-task-worker:20260529-164500)

  • (a) Deterministic repro: YES. clickhouse-client -q "SELECT * FROM icebergLocal('${USER_FILES_PATH}/x', 'Parquet', 'c0 Int32', 'lzma')" against the canonical binary prints BAD_ARGUMENTS every run; gate-flipped binary never does.
  • (b) Root cause: Bot's exact statement. TableFunctionObjectStorage::parseArgumentsImpl (src/TableFunctions/TableFunctionObjectStorage.h:58) calls StorageObjectStorageConfiguration::initialize with the default LoadingStrictnessLevel::CREATE, so the existing data-lake compression_method gate at line 144 fires for table functions too. The documented examples in TableFunctionObjectStorage.cpp / TableFunctionObjectStorageCluster.cpp were still advertising [, compression] for those functions, so copy-pasted invocations would throw BAD_ARGUMENTS.
  • (c) Fix matches root cause: Removed compression / compression_method from every data lake table-function example so the help text matches the runtime contract. Kept the rejection itself (engine + table function stay consistent) because the same write/read inconsistency from lzma compression should be rejected by DataLake engines #105644 applies to table-function INSERT and the hint is at best redundant for table-function SELECT (the data lake metadata describes the actual file format and compression). Non-data-lake examples keep compression.
  • (d) Test intent preserved: Yes. Existing engine-form rejection cases (tests 1, 2) and ATTACH backward-compat cases (tests 8, 9) are unchanged. The new table-function cases (tests 10, 11) are additive coverage.
  • (e) Both directions demonstrated:
    • Rejection enabled (canonical HEAD): test produces 13/13 reference output, 5/5 stable runs.
    • Rejection disabled locally (if (...) block body commented out + rebuilt): diff against reference produces exactly 1,2d0 BAD_ARGUMENTS BAD_ARGUMENTS and 12,13d9 BAD_ARGUMENTS BAD_ARGUMENTS — the four expected BAD_ARGUMENTS lines (two engine-form, two new table-function-form) drop out and nothing else changes. Gate restored after the negative-direction run, source verified clean via git diff.
  • (f) Fix is general: All 11 data lake table-function examples strings updated (1 non-cluster deltaLakeAzure + 10 cluster variants spanning Iceberg, Paimon, DeltaLake families across S3 / Azure / HDFS / Local). Non-data-lake s3, gcs, cosn, oss, hdfs, azureBlobStorage and their Cluster variants preserved. No source-level behavior change beyond what was already on this PR.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (commit 8286990)

(a) Deterministic repro: yes. With the new build, CREATE/ICEBERG/SELECT TABLE FUNCTION calls that include any explicit compression_method value (auto, AUTO, none, None, lzma, gzip) fail with BAD_ARGUMENTS on every iteration; default (no argument) and ATTACH of pre-existing metadata succeed.

(b) Root cause / mechanism: the previous gate allow-listed auto/none (also after lowercase canonicalisation), which left a user-facing API where two values were silently accepted as no-ops. The argument is meaningless for data lake engines because the file format codec is the authority. Per the directive, removed the allow-list and the lowercase canonicalisation; rejection now fires whenever the user actually supplied a value.

(c) Fix matches root cause: yes. New compression_method_user_provided flag on StorageObjectStorageConfiguration is set at every parsing site that takes the value from explicit user input (named-collection hasAny({"compression_method","compression"}), AST optional has_value() path in S3/Azure/Local/HDFS, and each Azure positional branch). Default code paths and the addStructureAndFormatToArgsIfNeeded placeholder injection leave the flag false. The gate is the only check left; no string compare, no case-conversion.

(d) Test intent preserved / new tests added: the regression test 04274_105644_lzma_compression_rejected_for_datalake is extended so explicit auto/AUTO/none/None now also produce BAD_ARGUMENTS (4 new expectations). Default case (no argument), ATTACH path with persisted lzma/gzip metadata, RESTORE path, and table-function form with lzma/gzip still covered.

(e) Both directions demonstrated: 5/5 stable passes with --no-random-settings against a fresh debug build (positive direction). Negative direction: the gate structure is unchanged from commit 006ab12a45eb which already verified the gate-disabled binary fails 04274 in a known pattern; this commit only narrows the condition (compression_method_user_provided instead of !empty && !=auto && !=none), so the same negative-direction guarantee holds.

(f) Fix is general: applies to all four data lake formats (Iceberg, DeltaLake, Hudi, Paimon) and to both the storage-engine and the table-function entry points. Non-data-lake configurations (s3(), azureBlobStorage(), hdfs(), file()) are unaffected because the gate sits inside if (configuration_to_initialize.isDataLakeConfiguration()). Docs (iceberg.md, paimon.md, deltalake.md) updated to remove the argument from the syntax samples.

Session id: cron:clickhouse-ci-task-worker:20260530-071500

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 30, 2026
Following review feedback on PR ClickHouse#105667, the public table-function docs
under `docs/en/sql-reference/table-functions/` still advertised the
`compression` / `compression_method` argument for the data lake table
functions (`iceberg*`, `deltaLake*`, `hudi*`, `paimon*`). Since commit
`82869907ac6f` the server rejects any explicit `compression_method` on
data lake engines and table functions, so users following these docs
would get `BAD_ARGUMENTS`.

Remove the argument from the syntax samples in:

- `iceberg.md`, `icebergCluster.md`
- `deltalake.md`, `deltalakeCluster.md`
- `hudi.md`, `hudiCluster.md`
- `paimon.md`, `paimonCluster.md`

and add the same explanatory paragraph used in the parallel integration
engine docs pointing users at the format-specific server setting (for
example `output_format_parquet_compression_method`).

Also drop the `compression` row from the argument tables in `hudi.md`
and `hudiCluster.md`.

Bot review:
ClickHouse#105667 (comment)
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (commit 16bda58)

(a) Deterministic repro: yes. Without the fix, grep '\[,compression\]\|\[,compression_method\]' docs/en/sql-reference/table-functions/{iceberg,deltalake,hudi,paimon}*.md returns 22 occurrences across the 8 data-lake table-function docs. With the fix it returns 0.

(b) Root cause: commit 82869907ac6f made the server REJECT explicit compression_method for data-lake engines and table functions at parsing time. That commit also cleaned up the integration-engine docs (docs/en/engines/table-engines/integrations/{iceberg,paimon,deltalake}.md) but the parallel table-function docs (docs/en/sql-reference/table-functions/{iceberg,deltalake,hudi,paimon}{,Cluster}.md) still advertised the now-rejected argument. Users following those examples would get BAD_ARGUMENTS.

(c) Fix matches root cause: yes. The same surgical edit as the prior cleanup — drop the rejected token from the syntax block and add the same explanatory paragraph pointing users at the format-specific server setting (for example output_format_parquet_compression_method). Also drops the now-obsolete compression row from the argument tables in hudi.md and hudiCluster.md where the argument was described in detail.

(d) Test intent preserved? / new tests: docs-only change; no test logic touched. The existing regression test 04274_105644_lzma_compression_rejected_for_datalake continues to cover the rejection behavior. No new tests are needed because docs files have no automated test coverage; the bot review itself is the validation.

(e) Both directions demonstrated: without fix → 22 occurrences across the 8 files; with fix → 0 occurrences, and a single new explanatory paragraph in each file. Diff stat: 8 files changed, 40 insertions(+), 26 deletions(-).

(f) Fix is general, not narrow: applied to all 8 data-lake table-function docs (iceberg, icebergCluster, deltalake, deltalakeCluster, hudi, hudiCluster, paimon, paimonCluster), matching the full scope of the server-side rejection. No PR-only narrow patch.

Bot inline comment addressed: #105667 (comment)

Session: cron:clickhouse-ci-task-worker:20260530-110000

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 30, 2026
Bot review on PR ClickHouse#105667 found a coverage gap in the data lake compression_method rejection introduced earlier in the PR.

The named-collection path in S3StorageParsedArguments::fromNamedCollection already handled both compression_method and the historical compression alias via hasAny(). The key-value engine/table-function path in S3StorageParsedArguments::fromAST (and parseFromDisk in Utils.cpp) only looked up the canonical compression_method key. When a user passed compression='lzma' as a key-value argument (for example, IcebergS3('<url>', compression='lzma')), the lookup missed, compression_method_user_provided stayed false, and the rejection in StorageObjectStorageConfiguration::initialize was silently bypassed, leaving the PR contract broken.

Add a fallback lookup at both sites: when getFromPositionOrKeyValue returns nullopt for 'compression_method', also check for the 'compression' alias in key_value_args. Mirrors the existing hasAny pattern used by fromNamedCollection.

Test 04274 extended with three engine-form cases: alias (compression=...), canonical (compression_method=...), and positional + alias (e.g. ENGINE = IcebergS3('<url>', 'Parquet', compression='lzma')). The rejection fires at initialize() before any S3 client is constructed, so a syntactically valid unreachable URL is sufficient and the test does not need network access.

Without this fix the CREATE TABLE silently falls through to Iceberg metadata loading and hangs trying to reach the unreachable URL (verified locally: 131+ seconds before kill). With the fix the rejection fires immediately and the test passes in 4.2 seconds.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate for 84ad4ec (alias coverage fix):

  • (a) Deterministic repro? Yes. CREATE TABLE foo (c0 Int) ENGINE = IcebergS3('http://localhost:11111/test/foo', compression = 'lzma') deterministically reproduces the rejection-bypass on the no-fix binary (CREATE TABLE hangs trying to reach the unreachable host; verified locally with the alias logic commented out, 131 s before kill).
  • (b) Root cause explained? Yes. S3StorageParsedArguments::fromAST and parseFromDisk read the key-value compression argument via getFromPositionOrKeyValue<String>("compression_method", ...), which only looks up the canonical key. When the user supplies compression = 'lzma' as a key-value argument, the lookup misses, compression_method_user_provided stays false, and the data lake rejection in StorageObjectStorageConfiguration::initialize is silently bypassed.
  • (c) Fix matches root cause? Yes. At both call sites the fix falls back to key_value_args.find("compression") when the canonical lookup returns nullopt. Mirrors the existing hasAny({"compression_method", "compression"}) handling in fromNamedCollection. No defensive plumbing.
  • (d) Test intent preserved? / New coverage? Yes. Existing assertions (positional rejection, default acceptance, ATTACH backward-compat, RESTORE backward-compat) are unchanged. Three new engine-form cases added: alias, canonical (regression coverage so the alias addition cannot silently shadow the canonical key), and positional + alias mix.
  • (e) Both directions demonstrated? Yes. With fix: 20/20 stable on --test-runs 20 --dont_retry_failures (4.2 s per run). Without fix (alias block temporarily disabled, full incremental rebuild): the new test 12 query hangs on Iceberg metadata loading against the unreachable host.
  • (f) Fix is general, not a narrow patch? Yes. Same gap class also patched at Utils.cpp:255 (parseFromDisk) which serves the Local / S3 / Azure fromDisk paths. Azure / HDFS / Local fromAST use positional-only parsing for the key-value position and do not hit this code path (verified via grep for getFromPositionOrKeyValue and key_value_args in each Configuration.cpp).

@mintlify

mintlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2f5dfa2.

Approve preview

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 21, 2026
Before this PR the key-value `compression` argument of the `S3` parser was
ignored: `S3StorageParsedArguments::fromAST` only looked up `compression_method`.
Commit 3ab402d made it an alias of `compression_method` so that the data
lake check rejects it, but that also activated the codec on every replay of an
existing definition (the check exempts `ATTACH`), and for plain `S3`, `S3Queue`
and `s3` table functions on every query.

Measured on a server upgraded from master with tables created there:
`IcebergS3(<url>, <key>, <secret>, 'Parquet', compression = 'lzma')` reads
`3 6` on master and fails with `LZMA_STREAM_DECODER_FAILED` on the PR head, and
`S3(<url>, <key>, <secret>, 'CSV', compression = 'gzip')` reads `2 9` on master
and fails with `CANNOT_DECOMPRESS`. With this change both read as on master,
before and after a restart, and a fresh data lake definition carrying the
argument is still rejected.

The argument is now kept in `ignored_compression_argument`, which only the data
lake check reads, also when `compression_method` is given next to it. The alias added to `parseFromDisk` by the same commit is
removed: its key-value arguments also occupy positional slots, so any
`compression = ...` there fails the literal check of another argument first
(measured on all six engine shapes and three table-function shapes), and the
branch was never reached.

04274 gets a replay case that reads rows back through a full-definition
`ATTACH` and a plain `s3` read with the argument (both fail on the PR head),
and a case with both arguments.
Addresses ClickHouse#105667 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f3e36a6

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 6/6) / numbers_with_step #2 dashboard confirmed regression (+18.6% client_time), arm per-start load-address placement, not from this PR #126977 (mine, merged after this run's tree was pinned; the run on c2f4197 includes it)
Sync - CH Inc sync (private, not actionable by me)

Mergeable Check and PR are rollups of the row above.

Session id: cron:clickhouse-maint-slot-13:20261021-163500

Data lake engines and table functions take the compression of their data files from the table
metadata, so an explicit `compression_method` (or key-value `compression`) argument is rejected,
except `auto`. A `format` the engine cannot store its data files in is rejected too. Existing tables
keep loading on `ATTACH`, `RESTORE` and secondary `CREATE`.

Closes ClickHouse#105644
ClickHouse#105667

Co-authored-by: Alexey Milovidov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PedroTadim
PedroTadim force-pushed the groeneai/fix-105644-reject-compression-method-for-datalake-engines branch from c2f4197 to c0155c1 Compare October 21, 2026 20:20
groeneai and others added 2 commits October 21, 2026 22:06
…ithout re-validating them

The data lake `compression_method` and `format` checks fire only for
`LoadingStrictnessLevel::CREATE`, so stored definitions of tables created
before the checks still load. Table functions always parsed their arguments
with `CREATE`, including when a persisted `CREATE TABLE t AS icebergLocal(...)`
definition is loaded at server startup (`DatabaseOnDisk::createTableFromAST`)
or by `ATTACH`/`RESTORE` (`InterpreterCreateQuery`). A table created on master
as `AS icebergLocal('<path>', 'Parquet', 'c0 Int32', 'none')` (or with
format `'CSV'`) read its rows there, and after an upgrade failed to load with
`Code: 36` on every restart.

`TableFunctionFactory::get` now takes the `mode` of the definition and hands
it to the table function before `parseArguments`; the object storage table
functions pass it to `StorageObjectStorageConfiguration::initialize`. A table
function in a query and a fresh `CREATE TABLE ... AS f(...)` still use
`CREATE` and are still rejected.

Test: 04274 case 23 replays such definitions (one per check) by a
full-definition `ATTACH` and by `DETACH DATABASE` / `ATTACH DATABASE`, which
takes the startup path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Case 23 reads a table defined `AS icebergLocal(...)` back after reloading its
database. With parallel replicas enabled in the default profile (the
`ParallelReplicas` configuration), `DatabaseOnDisk::createTableFromAST`
executes the table function as a read (`is_insert_query = false`), so
`TableFunctionObjectStorage::executeImpl` builds a `StorageObjectStorageCluster`.
Reading that table by name ships `FROM <table> AS __table1` to the replicas
unchanged (`updateQueryToSendIfNeeded` only rewrites table functions), and they
fail with `NOT_FOUND_COLUMN_IN_BLOCK`. A fresh `CREATE TABLE ... AS f(...)`
executes it with `is_insert_query = true` and never gets the cluster variant.

This is not caused by this change: on master the same read fails identically
for `AS icebergLocal(path)` with no extra argument, after `DETACH`/`ATTACH
DATABASE` and after a server restart. Neither a query-level nor a client-level
`enable_parallel_replicas = 0` avoids it, because the storage type is fixed when
the table is loaded, so the test is tagged `no-parallel-replicas`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 24b413e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 04274_105644_lzma_compression_rejected_for_datalake PR-caused (new case 23): with parallel replicas, a reloaded AS icebergLocal(...) table is loaded as a cluster storage that its replicas fail to read; master behaves the same fixed in this PR @ e1b1d16 (test tagged no-parallel-replicas)
Sync - CH Inc sync (private, not actionable by me)

Mergeable Check and PR are rollups of the rows above. The Bugfix validation FAIL rows are the expected inversion (all four checks succeeded).

Session id: cron:clickhouse-maint-slot-14:20261022-013600

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e1b1d16

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_asan_ubsan, azure, sequential, 1/2) / 05239_workload_drop_memory_reservation_in_use flaky, not from this PR (it changes data lake compression_method handling only; 3 of 3 reruns pass): KILL QUERY ... SYNC throws NOTHING_TO_KILL when DROP WORKLOAD has already ended the query. The same test failed 8 times on master and on 8 other PRs since 2026-10-21 #127158 (mine, open)
Performance Comparison (arm_release, master_head, 3/6) / dynamic_field_serialization_cache #0 not from this PR (no serialization change): client time 1.17 s -> 1.75 s (+49%), the one blocking dashboard regression (Not rerun: dashboard confirmationThreshold unavailable); the shard itself rates the query unstable. On arm this query is bimodal on both binaries: unstable on 281 PRs and in 88 master rows in 14 days #122464 (mine, open)
Mergeable Check, PR praktika rollups of the rows above #127158, #122464 (the owners of the rows above)
Sync - CH Inc sync (private, not actionable by me)

The Bugfix validation FAIL rows are the expected inversion (all four checks succeeded). CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261022-070007

alexey-milovidov and others added 3 commits October 23, 2026 01:04
Master now writes and reads `Vortex` data files in Iceberg tables (ClickHouse#112950):
the format is recorded per data file in the manifest, like the three formats
of the Iceberg specification. The per-engine `format` allowlist of this PR
rejected it with `BAD_ARGUMENTS`, which broke the Vortex Iceberg tests
05331, 05332, 05339, 05395 and 05407 after the master merge.

Add `Vortex` to the Iceberg set (all Iceberg engines, table functions and
catalog paths share it). `DeltaLake`, `Paimon` and `Hudi` keep rejecting it:
ClickHouse#112950 does not touch their readers or writers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2a7fd2e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / Logical error: Trying to deserialize data into Variant column with not global variants order (STID: 6636-4f2a) logical error, not from this PR (its diff is data lake compression_method handling): the server aborted while reading a SHARED path of a JSON column with the columns cache (SerializationObjectTypedSharedData::deserializeRequestedPaths from MergeTreeReaderWide::readRowsWithColumnsCache); the same abort hit 28 other PRs and master since 2026-10-26 #127867 (mine, open)
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / Server liveness check failed the same server abort as the row above #127867 (mine, open)
Mergeable Check, PR praktika rollups of the rows above #127867 (the owner of the rows above)

The Bugfix validation FAIL rows are the expected inversion (all four checks succeeded). CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261030-233003

Resolve the conflict in `04299_deltalake_local_path_traversal.sh`: master
removed the legacy Delta Lake reader and the per-reader loop, so take the
master version and keep this PR's switch from `RawBLOB` to `Parquet`.
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master (db4ed91c4b52) to resolve the conflict in 04299_deltalake_local_path_traversal.sh: master removed the legacy Delta Lake reader together with the per-reader loop in that test, so the merge takes the master version and keeps this PR's switch from RawBLOB to Parquet.

The previous CI failure (Logical error: Trying to deserialize data into Variant column with not global variants order in the ParallelReplicas, s3 storage stateless job) is in the JSON typed shared data reader and has nothing to do with this PR. It is fixed on master by da91460d2205 ("Keep the part's structure for SHARED paths taken from the substreams cache"), which this merge pulls in.

The three open review threads already have replies and are left to a maintainer, because each one is a design question rather than a missing fix: full-definition ATTACH is exempt (kept simple, as @alesapin asked), reload through a mutated named collection behaves the same as on master, and catalog-database definitions are validated on first use. @alesapin, the gate now follows your request (mode == LoadingStrictnessLevel::CREATE, which also exempts SECONDARY_CREATE for Replicated database recovery). Could you take another look?

# Conflicts:
#	src/Databases/DataLake/DatabaseDataLake.cpp
#	src/Databases/DataLake/DatabaseDataLake.h
alexey-milovidov and others added 2 commits November 14, 2026 21:32
Conflicts: `GlueCatalog.cpp` (master removed the schema cache member; keep
this PR's `table_definition_mode`), and `test_writes_create_table_bugs.py`
(moved by master to stateless test `05721`; this PR's switch from `CSV` to
`Parquet` is applied there).
Test `05632_iceberg_insert_text_format_file_cut`, added on master, created an
`IcebergLocal` table with the `JSONEachRow` format, which `CREATE` now rejects.
The race it covers is still reachable for tables defined before that check,
which load through `ATTACH`. The test now creates the Iceberg metadata with
`Parquet`, drops the table keeping its files, and attaches a full definition
(`ATTACH TABLE ... UUID`) with `JSONEachRow`. It is a `.sh` test because the
`UUID` of `ATTACH` must be a literal, and it also checks that every data file is
in the text format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master (e6256de9d058) to resolve the conflicts:

  • GlueCatalog.cpp: master removed the schema cache member from the constructor; the merge keeps this PR's table_definition_mode.
  • test_writes_create_table_bugs.py: master moved it to the stateless test 05721_iceberg_create_partition_by_truncate_without_width, so this PR's switch from CSV to Parquet now goes there.

There was also a semantic conflict. 05632_iceberg_insert_text_format_file_cut, added on master, created an IcebergLocal table with JSONEachRow, which CREATE now rejects. The race that test covers can still happen for tables defined before this check, so I kept the coverage instead of deleting the test. It is now a .sh test: it creates the Iceberg metadata with Parquet, drops the table and keeps the files, then runs ATTACH TABLE ... UUID ... with JSONEachRow. It also checks that every data file is .jsoneachrow. I ran both tests locally with clickhouse local on a build of the merged tree, and both match their references.

The three open review threads are design trade-offs that are still left for a maintainer to decide, as explained in their replies: the ATTACH exemption, reload through a mutated named collection, and eager validation of DataLakeCatalog arguments. This push does not change any of them.

context_copy,
/* with_table_structure */ false,
/* table_id */ nullptr,
table_definition_mode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Validate inherited arguments before creating a table in the catalog

A fresh REST database defined with DataLakeCatalog(url, key, secret, 'Parquet', 'none') is accepted, but CREATE TABLE d.`ns.t` (x String) ENGINE = IcebergS3 reaches this validation after committing the table remotely: maybeCreateTableInExternalCatalog calls catalog->createTableAtDefaultLocation at DatabaseDataLake.cpp:1283, then tryGetTableImpl at line 1286. This initialization rejects none, so the statement reports BAD_ARGUMENTS while the catalog already contains the new table. RestCatalog sends stage-create = false, and neither caller rolls the creation back. A retry finds an existing table, and DROP TABLE through the same database hits the same validation.

Please validate the inherited format/compression arguments before the external create, or make that operation transactional. Extend the existing REST catalog integration coverage to assert that a rejected CREATE TABLE leaves no table in the external catalog.

The test attaches a full table definition, so the server logs
"ATTACH TABLE query with full table definition is not recommended" as a
warning. The client receives server logs at `warning` level by default
and prints them to stderr, which fails the test in every stateless job
(seen in `Stateless tests (amd_asan_ubsan, db disk, distributed plan,
targeted)`; a run with `clickhouse local` does not show it). Receive only
errors, as the full-definition `ATTACH` cases of `04274` do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, fix conflicts.

Conflicts with the replayed-definition flag of ClickHouse#115581 and the
`DataLakeCatalog` replay rules of ClickHouse#132097:
- `TableFunctionFactory::get` and `getRequiredAccessOfTableFunction` take
  both `is_replayed_definition` and the loading `mode`; the data lake
  argument check of a table function keys on the mode, like the engine
  path, so a stored `CREATE TABLE ... AS <data lake function>` still loads
  wherever master now parses the function for the access check.
- `DatabaseDataLake::table_definition_mode` treats a replay marked with
  `isRecoveryFromStoredMetadata` as `ATTACH`, as ClickHouse#132097 does for the other
  fresh-`CREATE` validations.
- Glue catalog: `SecretString` engine definition from master, plus the mode.
- Docs and `.syntax` strings: master's workload identity forms of
  `deltaLakeAzure`, `deltaLakeAzureCluster` and `DeltaLakeAzure` without
  the `compression` slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master in 824a517, the PR is mergeable again.

Two conflicts needed more than picking a side:

The data lake tests of this PR pass locally, and a scan of the 58 data lake tests changed on master since the last merge finds no argument this PR rejects.

The merge of master in 824a517 kept master's `#include <algorithm>`
and the PR's own copy below `<fmt/ranges.h>`, which fails
`Build (arm_tidy)` with readability-duplicate-include.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai manual approve Manual approve required to run CI pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lzma compression should be rejected by DataLake engines

5 participants