Repository navigation
Allow to create table without providing credentials if catalog specified - #114477
Conversation
5d264fa to
fac5b01
Compare
|
Workflow [PR], commit [b7c10f2] AI ReviewSummaryThis PR teaches PR Metadata
Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit b7c10f2.
Changed lines: Changed C/C++ lines covered: 237/403 (58.81%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes57 object files changed (+188.32 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units719 translation units recompiled, 5554 s compile time in total, 719 of them have a recent master baseline.
|
asya-ch
left a comment
There was a problem hiding this comment.
Please address the open comments and I'll take another pass.
Also, a fair amount of the PR is refactoring. Would you mind moving the refactoring changes to an initial preparatory PR? It would make it easier to review.
641bf49 to
2910045
Compare
asya-ch
left a comment
There was a problem hiding this comment.
Did you test it manually? Could you please add a comment with queries that you ran on Unity and OneLake? (With PII obscured.)
3b881b5 to
cf9798e
Compare
Only Fabric registers tables it discovers in the lakehouse, so only there the initial metadata written just before `createTable` makes the catalog report the identifier as taken. For other REST catalogs a 409 is a real name collision again, which also keeps `splitLocationURI` from conflating locations on different schemes or accounts there. Also describe the location format handled in `OneLakeCatalog::getDefaultTableLocation`. Address review: #114477 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e::getDefaultTableEngineName` https://s3.amazonaws.com/clickhouse-test-reports/PRs/114477/e0d8aef808e5c441fed6365b36516b269eb1e00f/pr/build_arm_tidy/build_clickhouse/build_clickhouse.log #114477 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`tryGetDataLakeDatabase` used `std::static_pointer_cast`, so for `Iceberg*` / `DeltaLake*` tables in a regular `Atomic`/`Ordinary` database the database object was treated as `DatabaseDataLake`. `getCatalog` then locked a garbage mutex (`mutex lock failed: Invalid argument`) or hung, breaking every such table and killing the server in `test_database_iceberg`. Restore `std::dynamic_pointer_cast`, which returns nullptr for non-catalog databases as callers expect. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114477&sha=276ff65113ffd1527eb676e88da08fc7834faec5&name_0=PR PR: #114477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
||
| auto table_metadata = tryGetNewTableMetadata(settings, *catalog, name); | ||
| const auto catalog_storage_type = catalog->getStorageType(); | ||
| if (!table_metadata && !catalog_storage_type && catalog->createNamespaceIfNotExists(DataLake::parseTableName(name).first, /* location */ "")) |
There was a problem hiding this comment.
getDefaultTableEngineName now creates the namespace while just inferring an omitted engine, but unlike getEngineArgsForNewTable it never tracks or rolls that namespace back if inference later fails. For REST-style catalogs with no namespace location, createNamespaceIfNotExists(..., "") succeeds here, tryGetNewTableMetadata still returns nullopt, and CREATE TABLE db.\ns.tbl` (x UInt8)now throws fromcannotTellNewTableLocationafter leavingns` behind in the catalog.
This also happens earlier than the real create path for CREATE ... SETTINGS ..., because InterpreterSetQuery::applySettingsFromQuery calls this helper during settings splitting. Can this mirror the namespace_created cleanup contract from getEngineArgsForNewTable, or defer namespace creation until the path that can roll it back?
There was a problem hiding this comment.
@scanhex12, let's address this please. We need something like
if (namespace_created)
catalog->dropNamespace(namespace_name);
| f"CREATE TABLE {CATALOG_NAME}.`{root_namespace}.{table_name}` (x String) ENGINE = Iceberg", | ||
| settings={ | ||
| "allow_experimental_database_iceberg": 1, | ||
| "write_full_path_in_iceberg_metadata": 1, |
There was a problem hiding this comment.
Not a great user experience to have to specify write_full_path_in_iceberg_metadata=1. Do you think it would be feasible to flip the default (or even remove it) in a follow-up?
There was a problem hiding this comment.
It writes, for instance, s3://a/b/c instead of /a/b/c. I don’t remember exactly why, but this setting is important for the test suite.
| assert node.query(f"SELECT * FROM {CATALOG_NAME}.`{root_namespace}.{table_name}`") == "AAPL\n" | ||
|
|
||
|
|
||
| def test_create_without_engine_arguments(started_cluster): |
There was a problem hiding this comment.
nit: Up to you, but I would combine test_create_without_engine_arguments / test_create_without_engine and test_create_without_engine_arguments_storage_mismatch / test_create_without_engine_arguments_existing_namespace into parametrized tests. Would make it more readable. Same comment applies to the new tests in test_database_glue.
|
|
||
| auto table_metadata = tryGetNewTableMetadata(settings, *catalog, name); | ||
| const auto catalog_storage_type = catalog->getStorageType(); | ||
| if (!table_metadata && !catalog_storage_type && catalog->createNamespaceIfNotExists(DataLake::parseTableName(name).first, /* location */ "")) |
There was a problem hiding this comment.
@scanhex12, let's address this please. We need something like
if (namespace_created)
catalog->dropNamespace(namespace_name);
| result.storage_type = table_metadata.getStorageType(); | ||
| } | ||
|
|
||
| if (result.args.size() == 1) |
There was a problem hiding this comment.
nit:
| if (result.args.size() == 1) | |
| /// Only one arg means the user gave no credentials in CREATE DATABASE. Find them elsewhere. | |
| if (result.args.size() == 1) |
| @@ -46,7 +46,7 @@ class UnityV2Catalog final : public ICatalog, private DB::WithContext | |||
| Poco::JSON::Object::Ptr metadata_content) const override; | |||
|
|
|||
| /// Only checks that the schema exists. Unity schemas carry ownership and grants, so `CREATE TABLE` must not create them. | |||
There was a problem hiding this comment.
Let's add getDefaultTableLocation().
| void StorageAzureConfiguration::addStructureAndFormatToArgsIfNeeded( | ||
| ASTs & args, const String & structure_, const String & format_, ContextPtr context, bool with_structure) | ||
| { | ||
| /// The OneLake signature is a single storage URL: the account and the container are |
There was a problem hiding this comment.
I noticed you added OneLake tests in an earlier commit but they are gone now. Is it intentional?
There was a problem hiding this comment.
Yes — the dedicated OneLake zero-argument CREATE TABLE coverage moved into the shared e2e suite rather than staying in test_database_iceberg.
The current coverage is:
tests/integration/test_e2e_catalogs/test.py:730—test_create_without_engine_argumentstests/integration/test_e2e_catalogs/test.py:754—test_create_without_engine_arguments_storage_mismatch- parameterized across
biglake,glue, andonelakebycatalog_managerattests/integration/test_e2e_catalogs/test.py:174
There was a problem hiding this comment.
I decided that right now e2e tests are really flaky for some reason and it's better not to touch them, but I'll return my tests back
| } | ||
| catch (const DB::HTTPException & ex) | ||
| { | ||
| /// Fabric registers tables it discovers in the lakehouse, so it has already picked up the |
There was a problem hiding this comment.
I'm curious -- have you ran into the 409 issue? I know you mentioned offline you haven't ran this on a real OneLake catalog yet. Do our tests reproduce it?
There was a problem hiding this comment.
Not for this create-path 409 case.
The only current 409 coverage I found is tests/integration/test_database_iceberg/test.py:2780, which exercises updateMetadata conflicts during concurrent INSERT writers. I did not find a test that reproduces RestCatalog::createTable getting a 409 because OneLake auto-registered the freshly written initial metadata.
Only Fabric registers tables it discovers in the lakehouse, so only there the initial metadata written just before `createTable` makes the catalog report the identifier as taken. For other REST catalogs a 409 is a real name collision again, which also keeps `splitLocationURI` from conflating locations on different schemes or accounts there. Also describe the location format handled in `OneLakeCatalog::getDefaultTableLocation`. Address review: #114477 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
c60de1d to
4491836
Compare
…e::getDefaultTableEngineName` https://s3.amazonaws.com/clickhouse-test-reports/PRs/114477/e0d8aef808e5c441fed6365b36516b269eb1e00f/pr/build_arm_tidy/build_clickhouse/build_clickhouse.log #114477 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`tryGetDataLakeDatabase` used `std::static_pointer_cast`, so for `Iceberg*` / `DeltaLake*` tables in a regular `Atomic`/`Ordinary` database the database object was treated as `DatabaseDataLake`. `getCatalog` then locked a garbage mutex (`mutex lock failed: Invalid argument`) or hung, breaking every such table and killing the server in `test_database_iceberg`. Restore `std::dynamic_pointer_cast`, which returns nullptr for non-catalog databases as callers expect. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114477&sha=276ff65113ffd1527eb676e88da08fc7834faec5&name_0=PR PR: #114477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
6077c7e to
6473af8
Compare
`tryGetDataLakeDatabase` used `std::static_pointer_cast`, so for `Iceberg*` / `DeltaLake*` tables in a regular `Atomic`/`Ordinary` database the database object was treated as `DatabaseDataLake`. `getCatalog` then locked a garbage mutex (`mutex lock failed: Invalid argument`) or hung, breaking every such table and killing the server in `test_database_iceberg`. Restore `std::dynamic_pointer_cast`, which returns nullptr for non-catalog databases as callers expect. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114477&sha=276ff65113ffd1527eb676e88da08fc7834faec5&name_0=PR PR: #114477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…faultTableLocation` Only an absent database (`ENTITY_NOT_FOUND`) means "no default location". Other failures (IAM denial, expired credentials, transient outage) were turned into `std::nullopt` and surfaced as a misleading `BAD_ARGUMENTS` from `DatabaseDataLake::getEngineArgsForNewTable`. Throw them as `DATALAKE_DATABASE_ERROR`, like the other Glue methods do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e storage access `vended_credentials` is on by default, so the check for credentials that come from the catalog also rejected OneLake, BigLake and Paimon REST, which never pass storage credentials in the engine arguments and configure storage access in `applyCatalogSpecificConfiguration` instead. Exempt them, sharing the list with `buildTableEngineArgs` through `catalogConfiguresStorageAccess`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cation `GlueCatalog::createNamespaceIfNotExists` creates a database without `LocationUri`, so a zero-argument `CREATE TABLE` in a missing Glue namespace left an empty database behind and still failed to find the table location. Only REST catalogs assign a default location to a new namespace, so only they auto-create it now. #114477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
0ff4098 to
b7c10f2
Compare
| const std::string registered_metadata_path | ||
| = existing_properties ? existing_properties->iceberg_metadata_file_location : std::string{}; | ||
|
|
||
| if (!exists || splitLocationURI(registered_metadata_path) != splitLocationURI(new_metadata_path)) |
There was a problem hiding this comment.
This 409 fallback is still too weak for non-IF NOT EXISTS creates. For a fresh Iceberg table the initial metadata file is deterministically .../metadata/v1.metadata.json, so two concurrent CREATE TABLE ns.t ... statements with different schemas still produce the same new_metadata_path. If one request wins and the other lands here, the loser now returns success solely because the catalog points at the same path, even though the catalog may contain the winner's schema.
That breaks the CREATE TABLE contract by letting a conflicting create succeed. Can we verify that the existing table metadata matches the requested schema / partition spec / write order before accepting the 409, or otherwise keep this relaxed path for explicitly idempotent creates only?
…erg-table `master` gained a second way to create a table in a `DataLakeCatalog` (ClickHouse#114477): `ENGINE = IcebergS3` (or another catalog-family engine) without arguments, completed from the catalog by `completeEngineArgsFromCatalog` / `getEngineArgsForNewTable`. It also injected that engine into a `CREATE TABLE` without `ENGINE` through `IDatabase::getDefaultTableEngineName`. That overlaps the native engine-less path of this pull request, so the conflicts were reconciled as follows: - A `CREATE TABLE` without `ENGINE` keeps going through the native path of this PR (`DatabaseDataLake::createTable`). The `getDefaultTableEngineName` hook that rewrote it into a zero-argument engine is removed (`IDatabase`, `InterpreterCreateQuery`, `InterpreterSetQuery`, `DatabaseDataLake`). The native path now also places the table under the namespace location reported by the catalog (`ICatalog::getDefaultTableLocation`, e.g. Glue `LocationUri`) when no `default_base_location` is known, before falling back to `storage_endpoint`. - An explicit table engine without arguments keeps working as on `master`: `validateCreateTableEngine` only checks the engine family for it and leaves the location, the credentials and the storage backend to `getEngineArgsForNewTable`. - `ICatalog::createNamespaceIfNotExists` takes only the namespace, as on `master`: the catalog assigns the namespace location itself. - `ICatalog` keeps this PR's `createTable` (returns whether the table was created, takes the compression method and `if_not_exists`) and `dropTable` (`purge`, `if_exists`), plus `master`'s `getDefaultTableLocation`, `assignsLocationToNewNamespaces`, `writesInitialMetadata` and `removeSnapshots`. - `IcebergMetadata::createInitial`: the catalog writes the first metadata file when it manages the location or `writesInitialMetadata` (as on `master`), the existence check in the catalog is kept, and the leftover-files check, the version-hint cleanup and the `createTable` conflict handling of this PR are kept. - `RestCatalog::createTable` keeps this PR's `write-order` handling and `if_not_exists` and `master`'s forwarding of table properties and the `OneLake` idempotent re-registration. - Two `master` Glue tests that expected `cannot tell where table` also for a `CREATE TABLE` without `ENGINE` now run only with the explicit engine: the native path places such a table under `storage_endpoint`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… assigns After merging `master` (ClickHouse#114477), a `CREATE TABLE` without `ENGINE` in a `DataLakeCatalog` without `default_base_location` failed for an Iceberg REST catalog that does not report its storage type, while `master` created it under the location the catalog assigns to the namespace. The native path now does the same: when no base location is known, it asks the catalog for the location of the namespace (registering the namespace first if the catalog assigns locations to new namespaces), mapped through `storage_endpoint` the same way the table is read back, and only then falls back to `storage_endpoint`. `createNamespaceIfNotExists` no longer sends a namespace location (as on `master`), so the tests that checked the location derived for the namespace are updated: the table is placed under `default_base_location`, and the namespace location is whatever the catalog assigns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…th and without `ENGINE` `CREATE TABLE` without `ENGINE` and with a table engine without arguments now both take the location from `getNewTableLocation`: `default_base_location` (of the catalog or the database), then the location the catalog reports for the namespace, then `storage_endpoint`. Previously the engine without arguments ignored `default_base_location` and failed instead of falling back to `storage_endpoint`. A catalog that assigns table locations itself now rejects a table engine without arguments as well, as it already did with arguments. Related: ClickHouse#98670 (comment) Related: ClickHouse#114477
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow to create table without providing credentials if catalog specified. Earlier the query to create table looked like
create table catalog.table enigine = IcebergS3(url, key1, key2), but now we can create it viacreate table catalog.table enigine = IcebergS3Workflow [PR]
Sync PR [sync-upstream/pr/114477]
Version info
26.10.1.1677-master(included in26.10and later)