Skip to content

Treat a namespace location that is not a URI as no location in DataLakeCatalog CREATE TABLE - #131238

Merged
fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-131164-namespace-location-not-a-uri
Nov 14, 2026
Merged

fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-131164-namespace-location-not-a-uri

Conversation

@groeneai

@groeneai groeneai commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #131164
Related: #125006

Changelog category (leave one):

  • Improvement

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

CREATE TABLE without engine arguments in a DataLakeCatalog database now treats a namespace location that is not a URI, such as the not_used placeholder Databricks Unity Catalog reports for a schema of managed tables, as no location, so the catalog chooses the table location. Previously the query failed with Unexpected location format (NOT_IMPLEMENTED). Closes #131164.

Description

@ fm4v hit this on Databricks Unity (#131164): CREATE TABLE db.`<schema>.t` (id Nullable(Int64)) ENGINE = IcebergS3 in a DataLakeCatalog database fails with Unexpected location format: not_used/<table>. (NOT_IMPLEMENTED).

Databricks reports the location of a schema of managed tables as not_used. RestCatalog::getDefaultTableLocation appends the table name, and DatabaseDataLake::tryGetNewTableMetadata passed not_used/<table> to TableMetadata::setLocation, which throws for anything without ://.

tryGetNewTableMetadata now returns std::nullopt for such a location, the existing "catalog cannot tell the location" state that every caller already handles: with an Iceberg engine the create goes through createTableAtDefaultLocation (#125006) and the catalog places the table; without an engine the query fails with the existing BAD_ARGUMENTS "cannot tell where table ... has to be created" error. It uses the same :// predicate as setLocation, so no location accepted before changes behaviour. It is in the consumer, not in RestCatalog, because OneLakeCatalog::getDefaultTableLocation rewrites a scheme-less base location to abfss://.

Not Bug Fix: the success path exists only on master (#125006); on 26.10, which lacks it, the change would only replace NOT_IMPLEMENTED with the BAD_ARGUMENTS error.

Validation: the new integration test creates a namespace with location = not_used in the existing tabulario/iceberg-rest fixture, which returns it verbatim like Databricks. It fails on master with the issue's exact error and passes 50/50 with the fix. The rest of test_database_iceberg (two backup tests need root; they fail the same way on master locally) and the create tests of the ClickHouse REST catalog and Lakekeeper modules pass. I had no access to Databricks, so the fixture reproduces only its namespace response.


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

Version info

  • Merged into: 26.11.1.2313-master (included in 26.11 and later)

… table

Databricks Unity Catalog reports `not_used` as the location of a schema
with managed tables. `RestCatalog::getDefaultTableLocation` appends the
table name to it, and `DatabaseDataLake::tryGetNewTableMetadata` passed
`not_used/<table>` to `TableMetadata::setLocation`, which throws
`NOT_IMPLEMENTED` "Unexpected location format" for anything without
`://`. So `CREATE TABLE` without engine arguments in a `DataLakeCatalog`
database over Databricks failed before any request reached the catalog.

Treat such a location as unknown: `tryGetNewTableMetadata` returns
`std::nullopt`, which every caller already handles. With an Iceberg
engine the create goes to `createTableAtDefaultLocation` and the catalog
chooses the location; without an engine the query fails with the
existing "cannot tell where table has to be created" error.

The check is in the consumer rather than in `RestCatalog`, because
`OneLakeCatalog::getDefaultTableLocation` relies on the base returning a
scheme-less location that it rewrites to `abfss://`. It uses the same
`://` predicate as `setLocation`, so no location accepted before changes
behaviour.

Closes ClickHouse#131164

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 ❌ With a not_used namespace and no catalog-wide location, maybeCreateTableInExternalCatalog skips checkStorageTypeMatchesEngine, so ENGINE = IcebergLocal creates the S3 table the catalog chooses (DatabaseDataLake.cpp:1238) DISAGREE Before this change no check runs for this input either: setLocation throws NOT_IMPLEMENTED for every engine, including the matching IcebergS3. not_used names no storage, so there is nothing to check before the catalog creates the table. Skipping the check when the catalog cannot tell the location is the #125006 design (commit 7a485b5 replaced the throw with if (table_metadata)), already used for every namespace without a location. The table is read and written through the location the catalog reports. Changing that is a separate PR.
2 💡 A catalog that reports scheme-less paths now gets the table registered before ClickHouse fails to load it noted, not blocking No table of such a catalog is readable today: every table location goes through setLocation, which requires :// (RestCatalog.cpp:1855).

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261113-091300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The new test with a master binary fails every run: Code: 48. Unexpected location format: not_used/<table>. (NOT_IMPLEMENTED), from TableMetadata::setLocation via tryGetNewTableMetadata.
b Root cause explained? The namespace location not_used makes RestCatalog::getDefaultTableLocation return not_used/<table>; tryGetNewTableMetadata passed it to setLocation, which throws for anything without ://, before any catalog request.
c Fix matches root cause? Yes. The single consumer maps a non-URI value to the existing "no location" state (std::nullopt); no special case for not_used, no guard at the throw site.
d Test intent preserved / new tests added? New integration test in test_database_iceberg (existing fixture): checks the fixture returns not_used, the no-engine error, the ENGINE = IcebergS3 create, insert, select, and the catalog-chosen location.
e Both directions demonstrated? Yes. Fails on a master build of the same tree, passes with the fix 50/50.
f Fix is general across code paths? One consumer covers every producer (REST and its subclasses, Glue, Unity, Unity v2); OneLake rewrites its location before it. Explicit engine arguments never reach this code.
g Fix generalizes across inputs (params/datatypes/wrappers)? Probed namespace locations "", /tmp/warehouse, not_used (no engine: cannot tell where table; IcebergS3: created at the catalog-chosen location) and a real s3:// location (unchanged). Column types do not affect this path.
h Backward compatible? (maintainer-approved exception only) Yes. No setting or format change; every location accepted before is handled the same (same :// predicate); only a NOT_IMPLEMENTED error becomes a supported outcome.
i Invariants and contracts preserved? The value passed to setLocation is a URI, otherwise the location is unknown; all three callers already handle unknown. The early return happens before any state change; cannotTellNewTableLocation is unchanged.

Session id: cron:clickhouse-impl-slot-40:20261113-084000

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b18d234]

Summary: ✅


AI Review

Summary

Reviewed #131238 at b18d2345ba1569ecb501ae3eedf6d46389ce8931, including the prior discussion. Namespace locations without :// become unknown locations, allowing REST catalogs to place tables when an Iceberg engine is specified. No actionable findings.

Consumers checked for the expanded std::nullopt result:

  • getDefaultTableEngineName retries namespace discovery and reports BAD_ARGUMENTS when the storage type remains unknown.
  • getEngineArgsForNewTable rejects an unknown location for creation through the storage factory.
  • maybeCreateTableInExternalCatalog sends a create request without a location, then loads the actual table location from the catalog. InterpreterCreateQuery::doCreateTable invokes this path before the storage factory, so the explicit IcebergS3 case avoids the preceding rejection.
Missing context / blind spots
  • ⚠️ Integration CI results for the new test were not available at review time, and I did not run the test locally. The author reports failure before the change and 50 successful runs afterward. A completed CI run of test_create_without_engine_arguments_namespace_location_not_a_uri would independently confirm that evidence. The regression fixture reproduces the namespace response; live Databricks interoperability was not verified.
Final Verdict

✅ Approve the code change. Normal CI validation remains required before merge.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 13, 2026
@fm4v fm4v added the can be tested Allows running workflows for external contributors label Nov 13, 2026
@fm4v

fm4v commented Nov 13, 2026

Copy link
Copy Markdown
Member

@groeneai I added can be tested, so CI has not run on this PR yet.

One concern about the fix itself: on master, CREATE TABLE ... ENGINE = IcebergS3 without engine arguments builds the engine arguments from the location in DatabaseDataLake::getEngineArgsForNewTable. With this change tryGetNewTableMetadata returns std::nullopt for not_used, so that function goes to cannotTellNewTableLocation (directly, or after createNamespaceIfNotExists returns the same placeholder), and test_create_without_engine_arguments_namespace_location_not_a_uri expects the IcebergS3 create to succeed. Unless I misread the flow, the create needs a path where the catalog chooses the location: send the create without location (as RestCatalog::createTableAtDefaultLocation does) and take the location from the catalog's response for the engine arguments. At minimum, the error for not_used must stay the clean cannot tell where table one, never NOT_IMPLEMENTED.

Please run the new integration test, fix the flow if it fails, and keep working on this PR until CI is fully green: investigate every failed check, fix what belongs to this change, and for unrelated failures link the existing flaky-test issue or master failure in a comment.

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Nov 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

I ran test_create_without_engine_arguments_namespace_location_not_a_uri again on the PR head (b18d234, build ID 3141004f): it passes. With the base binary it fails with Unexpected location format: not_used/<table>. (NOT_IMPLEMENTED).

The IcebergS3 statement never reaches getEngineArgsForNewTable. For a CREATE, doCreateTable calls DatabaseDataLake::maybeCreateTableInExternalCatalog before the storage factory (InterpreterCreateQuery.cpp:3000). The storage factory is the only caller of getEngineArgsForNewTable (through completeEngineArgsFromCatalog, DataLakeConfiguration.h:460), and it runs only when that call returns nullptr. With catalog_type = 'rest' (RestCatalog::writesInitialMetadata() is true) and an Iceberg engine without arguments, the catalog creates the table itself:

  1. tryGetNewTableMetadata returns std::nullopt for not_used/<table>, before and after createNamespaceIfNotExists (DatabaseDataLake.cpp:1230, :1235). So the storage type check is skipped, the same as for a namespace without a location.
  2. createTableAtDefaultLocation sends the create request without location (:1280).
  3. tryGetTableImpl loads the new table from the catalog (:1283), so the engine gets the location from the catalog's response. That is the path you describe.

Server log of this run, with the table names shortened:

Ignoring location not_used/T_table reported by the catalog for new table T_namespace.T_table: it is not a URI
Ignoring location not_used/T_table reported by the catalog for new table T_namespace.T_table: it is not a URI
Created table T_namespace.T_table in the catalog of database demo

After that the test inserts a row, reads it back, and checks that the catalog put metadata_location under /<namespace>/<table>/metadata/.

getDefaultTableEngineName and getEngineArgsForNewTable still run when the catalog does not create the table: no ENGINE clause, a non-Iceberg engine, or a catalog without writesInitialMetadata. In those cases not_used now ends in cannotTellNewTableLocation (DatabaseDataLake.cpp:1102, :1139). The test checks this for the statement without ENGINE:
Code: 36. Catalog of database demo cannot tell where table T_namespace.T_table_default has to be created. Specify the location in the table engine arguments explicitly. (BAD_ARGUMENTS)

CI is running now. When it finishes I will post the ledger here and fix anything that comes from this change.

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b18d2345b with master 6036d472a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.69, programs/clickhouse-keeper ×0.77 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 6.9 s 12.2 s +7.3 s (+153%)
Compile time of recompiled translation units

7 translation units recompiled, 22 s compile time in total, 7 of them have a recent master baseline.

Job report

@fm4v
fm4v added this pull request to the merge queue Nov 14, 2026
Merged via the queue into ClickHouse:master with commit 89b0921 Nov 14, 2026
408 of 409 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 14, 2026
@clickhouse-gh clickhouse-gh Bot added comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
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-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataLakeCatalog: CREATE TABLE on Databricks fails with Unexpected location format: not_used/<table>

3 participants