Skip to content

Unify File/object-storage engines under the URL engine - #106093

Merged
alexey-milovidov merged 32 commits into
masterfrom
unify-url-engine-dispatch
Jul 7, 2026
Merged

alexey-milovidov merged 32 commits into
masterfrom
unify-url-engine-dispatch

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 29, 2026 •

Copy link
Copy Markdown
Member

Make the URL table engine and the url table function act as a unified wrapper that dispatches to the right backend based on the URL scheme, so a single uniform url('<scheme>://...') works regardless of where the data lives:

  • file:// → File
  • s3://, gs://, gcs://, oss:// → S3
  • az://, azure://, abfss://, abfs:// → AzureBlobStorage
  • hdfs:// → HDFS
  • http://, https:// and anything else → the URL engine itself (unchanged)

Scheme classification happens after the existing url_base relative-URL resolution, so a relative reference is first resolved against the base and then routed to the matching engine.

The dispatch reuses the existing engines by delegation rather than duplicating read/write/inference logic. The url table function builds the matching delegate table function via TableFunctionFactory::get and forwards schema inference, execution and the access-check engine name to it. The URL storage engine creator invokes the target engine's registered creator looked up from StorageFactory. gcs is added to the default S3 scheme mapper.

Implements item 1 of #59617.

SELECT * FROM url('file://data.csv', CSV, 'a UInt32, b String');
SELECT * FROM url('s3://clickhouse-public-datasets/hits_compatible/hits.csv');
CREATE TABLE t (a UInt32, b String) ENGINE = URL('file://data.csv', CSV);

Changelog category (leave one):

  • New Feature

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

The URL table engine and url table function now dispatch to the appropriate backend based on the URL scheme: file:// is served by the File engine, s3:///gs:///gcs:///oss:// by S3, az:///azure:///abfss:///abfs:// by AzureBlobStorage, hdfs:// by HDFS, and http(s):// by the URL engine as before. The url_base setting is applied before scheme dispatch. Only the S3 schemes resolved by the default url_scheme_mappers are dispatched; other S3-compatible vendor schemes (cos, obs, ...) are not, and require using the s3 engine/function directly.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.7.1.635 (included in 26.7 and later)

Make the `URL` table engine and the `url` table function dispatch to the
right backend based on the URL scheme, so a single uniform `url('<scheme>://...')`
works regardless of where the data lives:

- `file://` -> `File`
- `s3://`, `gs://`, `gcs://`, `oss://`, `cos://`, ... -> `S3`
- `az://`, `azure://`, `abfss://` -> `AzureBlobStorage`
- `hdfs://` -> `HDFS`
- `http://`, `https://` and anything else -> the `URL` engine itself (unchanged)

The dispatch reuses the existing engines by delegation rather than duplicating
read/write/inference logic. The `url` table function builds the matching
delegate table function via `TableFunctionFactory::get` and forwards schema
inference, execution and the access-check engine name to it. The `URL` storage
engine creator invokes the target engine's registered creator looked up from
`StorageFactory`.

Scheme classification happens after the existing `url_base` relative-URL
resolution, so a relative reference is first resolved against the base and then
routed to the matching engine. `gcs` is added to the default S3 scheme mapper.

This implements item 1 of #59617

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0b235b0]

Summary: ✅


AI Review

Summary

This PR makes the URL engine and url table function dispatch recognized non-HTTP schemes to the existing File, S3, AzureBlobStorage, and HDFS backends while preserving URL syntax and table metadata behavior. I reviewed the current diff, prior discussion, dispatch and persistence paths, access-control checks, planner-capability forwarding, and the targeted regression coverage; I do not see any remaining correctness, safety, or missing-evidence issue that warrants an inline finding.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label May 29, 2026
Comment thread src/Storages/StorageURL.cpp Resolved
Comment thread src/Storages/StorageURL.cpp Resolved
Comment thread src/IO/S3/URI.cpp Resolved
Comment thread src/TableFunctions/TableFunctionURL.cpp Resolved
Comment thread src/TableFunctions/TableFunctionURL.h Resolved
@Michicosun Michicosun self-assigned this May 29, 2026
…ngine dispatch

The `Style check` job flagged the `catch (...)` in `registerStorageURL`
(unified URL engine scheme dispatch) as silently swallowing exceptions.
The catch is intentional: when the first engine argument is not a
positional string literal (e.g. a named collection), we fall through to
the plain `URL` engine behavior. Move the explanatory comment onto the
`catch` line and mark it with `Ok:` so the `check_catch_all` style rule
recognizes it as deliberate.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Storages/StorageURL.cpp Resolved
alexey-milovidov and others added 3 commits May 30, 2026 02:25
…ispatch

Follow-up to the URL-engine scheme dispatch, addressing the automated review on PR #106093:

- Persistence: the `URL` engine no longer mutates the persisted `ENGINE = URL(...)`
  arguments when dispatching. The delegate storage is built from a separate argument
  list and wrapped in a `StorageProxy` (`StorageURLSchemeDispatch`) that keeps the
  IStorage no-op `addInferredEngineArgsToCreateQuery`, so `SHOW CREATE`, `DETACH`/`ATTACH`
  and restart keep the original `URL(...)` syntax and re-dispatch on reload. This also
  avoids a `LOGICAL_ERROR` from the Azure engine, which requires at least 3 arguments.

- Access control: dispatching now re-checks `TABLE ENGINE` privilege for the target
  engine on `CREATE`, so a user granted only `URL` cannot create File/S3/Azure/HDFS
  backed tables. The `url` table function reports the delegate's source as its function
  URI so source-access filters apply to the resolved path/URL.

- Argument forms: the engine classifies the scheme via a cloned `getConfiguration`, so
  key-value and named-collection `url=` forms dispatch consistently.

- `headers(...)` is now rejected with a clear error when dispatching to a non-URL
  scheme, instead of being silently dropped.

- `gcs` is added to the default `url_scheme_mappers` in `config.xml` (the config
  overrides the built-in fallback, so the fallback entry alone was not enough).

- Tests: added regressions for reload-safety (`system.tables` engine + `DETACH`/`ATTACH`)
  and `headers(...)` rejection.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ith Ok

The check_catch_all style rule flags the catch(...) around the probe
getConfiguration in tryDispatchURLEngineByScheme. The catch is intentional:
when the arguments are not a URL-engine shape we can classify, we fall through
to the plain URL engine path which reports any real errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…unify-url-engine-dispatch

# Conflicts:
#	src/Storages/StorageURL.cpp
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the automated review (pushed as follow-up commits):

  • Persistence (blocker): the URL engine no longer rewrites the persisted ENGINE = URL(...) arguments. The delegate is built from a separate argument list and wrapped in a StorageProxy (StorageURLSchemeDispatch) that keeps the no-op addInferredEngineArgsToCreateQuery, so SHOW CREATE, DETACH/ATTACH and restart keep the original URL(...) syntax and re-dispatch on reload. This also avoids a LOGICAL_ERROR from the Azure path (which requires ≥ 3 args).
  • Engine access (blocker): dispatch now re-checks TABLE ENGINE on the target engine on CREATE, so a user granted only URL cannot create File/S3/Azure/HDFS-backed tables. Verified: a URL-only user is denied ENGINE = URL('s3://...') but allowed ENGINE = URL('http://...').
  • Table-function access (blocker): getFunctionURI now returns the delegate's source (path / resolved URL) so source-access filters apply correctly.
  • Key-value / named-collection forms (major): the engine classifies the scheme via a cloned getConfiguration, so all argument forms dispatch consistently.
  • gcs mapper (major): added to the default url_scheme_mappers in config.xml (the config overrides the built-in fallback).
  • Dropped headers (major): headers(...) is now rejected with a clear error on dispatched schemes instead of being silently dropped.
  • Tests: added regressions for reload-safety (system.tables engine + DETACH/ATTACH) and headers(...) rejection.

The three CI failures on the previous commit were unrelated to this change (Stress px != 0 / signal 6 in QueryPlanResourceHolder from a DISTINCT … extremes=1, max_memory_usage='4Mi' query; BuzzHouse ASan stack-use-after-scope in Poco::ThreadPool at server startup). The LLVM coverage drop was the new dispatch lines; the added regressions cover more of them.

Comment thread src/Storages/StorageURL.cpp Resolved
Comment thread src/Storages/StorageURL.cpp Resolved
… in URL dispatch

Two correctness fixes for the unified `URL` engine / `url` table function
scheme dispatch, flagged by the automated review after the previous follow-up:

- Schema-inferred metadata (`StorageURLSchemeDispatch`): for a `CREATE TABLE t
  ENGINE = URL('file://...')` without an explicit column list, `columns_` is
  empty because the `URL` engine declares `supports_schema_inference` and the
  structure is inferred inside the delegate storage constructor. The proxy used
  to initialize its metadata from the empty `columns_`, so it persisted an empty
  column list and exposed a snapshot with no physical columns. It now copies the
  inferred columns from the delegate when explicit columns were not provided.

- Delegated source-access URI (`TableFunctionURL`): `buildDelegate` approximated
  the delegate's access URI as `filename` for every object-storage target. For
  `AzureBlobStorage` the real `azureBlobStorage` source check uses
  `StorageAzureConfiguration::getRawURI` (only `blob_path.path`), so filtered
  source grants diverged from calling the delegate directly. The wrapper now
  takes `delegate_function_uri` from the delegate's own `getFunctionURI`, which
  is authoritative for all schemes (`file` → empty, `s3`/`hdfs` → full URL,
  `azure` → blob path). `getFunctionURI` is made public for this.

Adds a regression for `ENGINE = URL('file://...')` without an explicit column
list (column count, reload across `DETACH`/`ATTACH`).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Follow-up addressing the remaining automated-review findings (commit d113abd):

  • Inferred metadata (blocker): StorageURLSchemeDispatch initialized its metadata from columns_, which is empty for a schema-inferred CREATE TABLE t ENGINE = URL('file://...') (the structure is inferred inside the delegate constructor since URL declares supports_schema_inference). It would persist an empty column list. The proxy now copies the inferred columns from the delegate when explicit columns are not provided. Verified: system.columns reports the inferred c1/c2, and the structure survives DETACH/ATTACH. Regression added.

  • Delegated source-access URI (blocker): buildDelegate approximated the delegate URI as filename for all object-storage targets, so AzureBlobStorage filtered grants diverged from calling azureBlobStorage directly (which checks StorageAzureConfiguration::getRawURI = blob_path.path). The wrapper now takes delegate_function_uri from the delegate's own getFunctionURI — authoritative for every scheme (file → empty, s3/hdfs → full URL, azure → blob path). getFunctionURI is made public for this.

  • url_base persistence on dispatched engines (open, deferred): I left this one as a design call. The dispatch path intentionally keeps the persisted URL(...) arguments untouched (to preserve SHOW CREATE syntax and avoid the Azure ≥ 3-args LOGICAL_ERROR), which means an engine-level SET url_base + relative reference resolving to a non-http scheme is not re-materialized into the stored argument, so a DETACH/ATTACH without that session setting reloads as plain URL. A compatible fix exists (materialize the resolved URL into the same URL argument position, mirroring StorageURL::addInferredEngineArgsToCreateQuery, preserving the urlHasUserInfo exception), but it touches the deliberate "leave args untouched" decision and the named-collection/key-value forms, so leaving it for a separate decision.

Comment thread src/Storages/StorageURL.cpp Resolved
…spatch

# Conflicts:
#	src/Storages/StorageURL.cpp
Comment thread src/TableFunctions/TableFunctionURL.cpp Resolved
Comment thread src/Storages/StorageURL.cpp Resolved
alexey-milovidov and others added 2 commits June 2, 2026 20:41
…n scheme dispatch

Fix four issues raised in review of the unified `URL` engine/function scheme dispatch:

- `url_base` persistence: when a relative reference is resolved against `url_base`
  and dispatched to a backend, the wrapper now materializes the resolved URL back
  into the persisted `URL(...)` args (via the new static
  `StorageURL::materializeResolvedURLInEngineArgs`, extracted from
  `addInferredEngineArgsToCreateQuery`). Otherwise `DETACH`/`ATTACH` or restart
  without `url_base` would load the scheme-less reference as a plain `URL` table
  instead of re-dispatching to the original backend. Userinfo URLs are still skipped
  to avoid leaking credentials via `SHOW CREATE TABLE`.

- `TRUNCATE`: `StorageURLSchemeDispatch` now overrides `supportsTruncate`/`truncate`
  to preserve the `URL` engine semantics (not supported), instead of forwarding to
  the delegate and silently truncating local files or removing object-storage keys
  under a table declared as `URL`.

- `RENAME`: the wrapper now performs a metadata-only rename like a plain `URL`
  table, instead of forwarding to the delegate (which would move/remove backend
  data or throw for user-defined-file `File` delegates).

- `urlCluster`: a non-`http(s)` scheme passed to `urlCluster` is now rejected with a
  clear error instead of silently building a non-clustered delegate and running the
  read on the initiator, ignoring the requested cluster. `isClusterFunction` is made
  protected so `TableFunctionURL` can branch on the cluster context.

The regression test is extended to cover all four cases and renumbered to `04305`
to avoid a collision with a test added on master.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Storages/StorageURL.cpp Resolved
alexey-milovidov and others added 2 commits June 5, 2026 05:51
`StorageURLSchemeDispatch` derives from `StorageProxy`, so calling
`IStorage::renameInMemory` and `IStorage::truncate` from it is a
grandparent virtual call that `clang-tidy` flags as
`bugprone-parent-virtual-call` (warnings-as-errors in the `arm_tidy`
build).

- `renameInMemory`: the override was byte-identical to
  `StorageProxy::renameInMemory` (`nested->renameInMemory` followed by
  `IStorage::renameInMemory`), so it is removed entirely. The `rename`
  override calls the virtual `renameInMemory`, which now resolves to
  `StorageProxy::renameInMemory` with the same behavior.
- `truncate`: must deliberately bypass `StorageProxy::truncate` (which
  forwards to the delegate and would truncate the backing file/object)
  and use the `IStorage` default, which throws. Annotated with
  `NOLINT(bugprone-parent-virtual-call)`, mirroring `StorageTableProxy`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106093&sha=e4623598db443198f57bc2529fce349ecb5ce180&name_0=PR&name_1=Build%20%28arm_tidy%29

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Fixed the arm_tidy build failure (the only red job; the other builds were DROPPED as downstream of it).

clang-tidy flagged bugprone-parent-virtual-call at the two IStorage:: calls in StorageURLSchemeDispatch (which derives from StorageProxy, so these are grandparent virtual calls):

  • renameInMemory: the override was byte-identical to StorageProxy::renameInMemory (nested->renameInMemory then IStorage::renameInMemory), so I removed it entirely. rename calls the virtual renameInMemory, which now resolves to StorageProxy's with the same behavior.
  • truncate: must deliberately bypass StorageProxy::truncate (which would forward to the delegate and truncate the backing file/object) and use the IStorage default, which throws. Annotated // NOLINT(bugprone-parent-virtual-call), mirroring StorageTableProxy.

Also merged master (the branch was 554 commits behind and red) and verified StorageURL.cpp compiles clean.

Remaining open automated-review thread — inferred format persistence on dispatched engines: this is in the same category as the url_base persistence you already deferred. The gap is narrow (only an extensionless source with format = auto; a source with a recognizable extension resolves the format from the name at re-dispatch, and explicit format is already kept in the args). Persisting the delegate's inferred format is not a one-liner like StorageURL::addInferredEngineArgsToCreateQuery's updateStructureAndFormatArgumentsIfNeeded call, because the dispatch wrapper would have to read the inferred format back out of the delegate, and there is no uniform getFormatName across File/S3/AzureBlobStorage/HDFS. Happy to implement it (extract the format per engine and materialize it into the URL(...) args next to the resolved URL) if you want to close that case now, or leave it deferred alongside url_base.

Comment thread src/Storages/StorageURL.cpp Resolved
The `URL` engine description exposed via `system.table_engines.description`
listed only `abfss://` for the Azure backend, while `classifyURLScheme`
dispatches both `abfss` and `abfs` and the Markdown docs
(`docs/en/engines/table-engines/special/url.md`,
`docs/en/sql-reference/table-functions/url.md`) already list `abfs://`.

Add `abfs://` alongside `abfss://` in the in-server engine docs so all
user-facing descriptions match the actual scheme contract.

Addresses the automated review finding on `StorageURL.cpp`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the ⚠️ Request changes automated review (commit 9f444f56581).

  • Registered URL engine docs (the sole minimum required action): added abfs:// alongside abfss:// in the .description of the URL engine in StorageURL.cpp (exposed through system.table_engines.description). classifyURLScheme already dispatches both abfs and abfss, and the Markdown docs (docs/en/engines/table-engines/special/url.md, docs/en/sql-reference/table-functions/url.md) already listed abfs://, so this only closes the in-server-docs drift the review flagged.
  • Changelog: updated the Azure scheme list in the PR description to az:///azure:///abfss:///abfs:// to match the supported contract.

The two CI failures are unrelated to this change (the PR touches neither test) and both have open tracking issues:

No master re-merge: the branch is behind but the merge-base is from 2026-06-29 (< 1 day), there are no conflicts, and neither red is fixable by merging master (both fire on master).

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continue-PR status (automated pass, 2026-06-30): analysis + thread reply only — no code changes, no re-merge, no force actions.

AI Review verdict: ✅ Approve ("no remaining blocking issues in the changed code").

Review threads: 28/29 resolved; 1 unresolved — @Michicosun's design question on classifyURLScheme ("rewrite this as a regular expression matcher?"). Replied with the rationale for keeping the explicit scheme == ... comparisons (small fixed enumeration, each branch maps to a different backend and carries its own rationale comment; a regex can't express the per-group → target mapping without extra bookkeeping and is costlier). Left unresolved for your call rather than changing the code.

CI (commit 9f444f56): the two reds are both unrelated to this PR:

  • AST fuzzer (amd_debug) — Block structure mismatch in A stream in IntersectOrExceptStep::updateOutputHeader (STID 0993-2cc2) = tracked known fuzzer flake #108210; CIDB shows it firing across many PRs daily (5 PRs on 06-30, 8 on 06-27, …) and it has nothing to do with URL-engine dispatch. Could not re-run ("job cannot be rerun").
  • Integration tests (amd_llvm_coverage, 4/8) — Docker registry 503 Service Unavailable pulling an image from ch-docker-mirror (infra), not a test failure. Re-triggered (now queued).

Merge base: behind master but the last master merge was <1 day ago and the reds are not master-fixable, so no re-merge.

State: MERGEABLE / BLOCKED (awaiting human approval; @Michicosun review requested).

…spatch

# Conflicts:
#	src/Storages/StorageURL.cpp
#	src/TableFunctions/TableFunctionURL.cpp
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continue-PR status (automated pass, 2026-06-30): merged master and resolved conflicts.

The branch was 740 commits behind master, and master had actively evolved the exact files this PR rewrites (StorageURL.cpp, StorageURL.h, TableFunctionURL.cpp), so I merged origin/master (merge commit 0b235b0f702). Conflicts in src/Storages/StorageURL.cpp and src/TableFunctions/TableFunctionURL.cpp were resolved as follows:

  • Unified the resolved-URL rewriter. Both this PR and master independently extracted the URL-materialization logic out of addInferredEngineArgsToCreateQuery into a static helper: this PR added materializeResolvedURLInEngineArgs (always skips userinfo), while master added the more general overrideURLInEngineArgs(args, url, context, skip_userinfo) (and a second call site that passes skip_userinfo=false). I dropped this PR's duplicate and reused master's overrideURLInEngineArgs, mapping both of this PR's call sites (the plain URL engine's addInferredEngineArgsToCreateQuery and the StorageURLSchemeDispatch wrapper) to overrideURLInEngineArgs(..., /*skip_userinfo=*/ true), which preserves the original always-skip behavior.
  • Composed registerStorageURL. Kept this PR's scheme dispatch (tryDispatchURLEngineByScheme) at the top, then fell through to master's new HTTP index-page wildcard path (urlPathHasListableGlobs → StorageObjectStorage with StorageWebConfiguration). master's checkExperimentalURLWildcardFromIndexPages / makeWebObjectStorageEngineArgs helpers and the SUPPORT_IS_DISABLED error code are kept alongside this PR's BAD_ARGUMENTS.
  • Removed a duplicate #include <Storages/ObjectStorage/StorageObjectStorage.h> introduced by the merge (to keep clang-tidy/arm_tidy clean).

Verified the resolution compiles: StorageURL.cpp.o, TableFunctionURL.cpp.o, and gtest_storage_url_scheme_dispatch.cpp.o all build cleanly against current master. The PR's net diff versus master is unchanged in scope (the URL-dispatch feature only).

CI before the merge: the sole non-flaky-infra failure was AST fuzzer (amd_debug) → Logical error: Block structure mismatch in A stream: different columns in IntersectOrExceptStep::updateOutputHeader (STID 0993-2cc2). This is a pre-existing master flake tracked in #108210 (40 hits across 34 PRs on 2026-06-30 alone, last seen on master at 21:45Z today), in INTERSECT/EXCEPT query-plan handling — unrelated to URL-engine dispatch. A fresh CI run is now in flight on the merge commit.

AI Review verdict: ✅ Approve. The one open review thread is a design discussion (regex vs. explicit scheme == ... comparisons) that already has a reply; left for the reviewer.

@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.70% +0.10%
Branches 77.60% 77.70% +0.10%

Changed lines: Changed C/C++ lines covered: 261/320 (81.56%) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continue-PR status (automated pass, 2026-07-01): analysis + flaky-job rerun only — no code changes, no re-merge.

CI on the current head 0b235b0f702 (post-master-merge): green except a single non-required red.

  • Sole failure: Stress test (arm_ubsan) → Hung check failed, possible deadlock found. This is the known chronic infra flake tracked by Hung check failed, possible deadlock found #107941 (open). The hung-check log tail is a BSONEachRow format query (02685_bson2.sql); there are no StorageURL/classifyURLScheme/SchemeDispatch/TableFunctionURL frames, so it is unrelated to this PR's URL-dispatch changes.
  • Mergeable Check: ✅ SUCCESS — the Stress test is not a required gate, so this red does not block merge. Reran the failed job (28480723356 --failed) to aim for a clean overall report.
  • CH Inc sync: pending (private clickhouse-private#59308) — not failed, so no action.

Review: AI Review verdict is ✅ Approve ("no remaining correctness, safety, or missing-evidence issue"). The single unresolved inline thread (regex vs. explicit scheme == comparisons, StorageURL.cpp) has been answered as a deliberate design choice.

No re-merge: merge base 1a000987bea is ~7h old (well under a day), and master has not touched any of the 26 files this PR changes since then.

Effectively ready — blocked only on human approval and the private sync draining.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continue-PR status (automated pass, 2026-07-01): analysis only — no code changes, no re-merge, no reruns.

CI on the current head 0b235b0f702: fully green. Since the previous pass, the two remaining non-green items both resolved on their own:

  • Stress test (arm_ubsan) — the reran job now passes; all 12 Stress variants are SUCCESS. This was the chronic Hung check failed, possible deadlock found flake (Hung check failed, possible deadlock found #107941), which the log tail confirmed was a BSONEachRow query with no StorageURL/classifyURLScheme/SchemeDispatch/TableFunctionURL frames — unrelated to this PR.
  • CH Inc sync — the private sync has drained to SUCCESS.

All 174 rollup checks are now SUCCESS/SKIPPED/NEUTRAL with 0 failures. Mergeable Check, PR, and Style check are all green; state is MERGEABLE / CLEAN.

AI Review verdict (current head): ✅ Approve — "no remaining correctness, safety, or missing-evidence issue."

Review threads: 28/29 resolved. The single unresolved thread is @Michicosun's design question (regex matcher vs. the explicit scheme == ... comparisons in classifyURLScheme), already answered with the rationale for keeping the explicit form; left for the reviewer's call rather than changing the code.

No re-merge: merge base 1a000987bea is ~10h old (well under a day), and although the branch is behind master, the head is MERGEABLE/CLEAN and fully green, so re-merging would only churn a green report.

Effectively ready — blocked only on human approval (@Michicosun review requested).

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, finished reviewing.

@alexey-milovidov alexey-milovidov self-assigned this Jul 7, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 7, 2026
Merged via the queue into master with commit 2834291 Jul 7, 2026
343 of 344 checks passed
@alexey-milovidov
alexey-milovidov deleted the unify-url-engine-dispatch branch July 7, 2026 22:17
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 7, 2026
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 10, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it, use `pg_strcasecmp` to compare
`COPY` options like Postgres does.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 10, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it, use `pg_strcasecmp` to compare
`COPY` options like Postgres does.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 13, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it, use `pg_strcasecmp` to compare
`COPY` options like Postgres does.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 13, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it switch to using the Postgres
option parsing functions to ensure we get valid values.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 13, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it switch to using the Postgres
option parsing functions to ensure we get valid values.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 13, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it switch to using the Postgres
option parsing functions to ensure we get valid values.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 13, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Set up a memory context callback to release the chDB connection when we
exit, whether through an error, interrupt, or normal exit.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it switch to using the Postgres
option parsing functions to ensure we get valid values.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
theory added a commit to ClickHouse/pg_chdb that referenced this pull request Jul 14, 2026
Implement the chDB streaming SELECT and INSERT logic to execute the
queries sent to chDB. Just emit SELECT results as a NOTICE for now, and
leave the scaffolding for sending INSERT data in a no-op loop for a NULL
variable for now. Carefully copy an error message and free all of the
chDB allocated memory before raising a Postgres exception, to keep
memory management properly separated and clean.

The one bit of funky-ness is stripping out a `Request ID:` line from an
error message so that errors are consistent and thus testable.

Set up a memory context callback to release the chDB connection when we
exit, whether through an error, interrupt, or normal exit.

Refactor the chDB query generation to use `auto` as the value for
otherwise unset `format` and `structure` arguments; encapsulate this
behavior in `append_format_structure_compression()`, since the S3, GCS,
and ABS functions all handle these two arguments, along with
`compression`, in the same way and order.

Speaking of ABS, add `azureURLParts` and `parse_azure_url`, ported from
ClickHouse/ClickHouse#106093, to extract the account URL, container
name, and storage path from the URL and generate the
`azureBlobStorage()` SQL with those parts. Also change the `gcs` URL to
`https`, the scheme recognized by `gcs()`.

Add a new `COPY` option, `timeout`, to allow the user to set a request
timeout. Defaults to 30s. While at it switch to using the Postgres
option parsing functions to ensure we get valid values.

Add the `settings` constant and use it to construct settings for each
query, appending those settings required for each function, including
the timeout, as it varies for each function.

Update the tests to call real public URLs on S3 and GCS. The `NOTICE`s
show that their contents are properly fetched for `COPY FROM` unless the
credentials are incorrect; `COPY TO` currently fails because we're not
sending any data and because we don't have permission anyway.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ispatch

Follow-up to the URL-engine scheme dispatch, addressing the automated review on PR ClickHouse#106093:

- Persistence: the `URL` engine no longer mutates the persisted `ENGINE = URL(...)`
  arguments when dispatching. The delegate storage is built from a separate argument
  list and wrapped in a `StorageProxy` (`StorageURLSchemeDispatch`) that keeps the
  IStorage no-op `addInferredEngineArgsToCreateQuery`, so `SHOW CREATE`, `DETACH`/`ATTACH`
  and restart keep the original `URL(...)` syntax and re-dispatch on reload. This also
  avoids a `LOGICAL_ERROR` from the Azure engine, which requires at least 3 arguments.

- Access control: dispatching now re-checks `TABLE ENGINE` privilege for the target
  engine on `CREATE`, so a user granted only `URL` cannot create File/S3/Azure/HDFS
  backed tables. The `url` table function reports the delegate's source as its function
  URI so source-access filters apply to the resolved path/URL.

- Argument forms: the engine classifies the scheme via a cloned `getConfiguration`, so
  key-value and named-collection `url=` forms dispatch consistently.

- `headers(...)` is now rejected with a clear error when dispatching to a non-URL
  scheme, instead of being silently dropped.

- `gcs` is added to the default `url_scheme_mappers` in `config.xml` (the config
  overrides the built-in fallback, so the fallback entry alone was not enough).

- Tests: added regressions for reload-safety (`system.tables` engine + `DETACH`/`ATTACH`)
  and `headers(...)` rejection.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…Dispatch

The `URL` engine dispatches non-HTTP schemes to a delegate (`File`/object
storage) wrapped in `StorageURLSchemeDispatch`, which is a `StorageProxy`. The
proxy forwards `supportsSubcolumns` and `supportsPrewhere`, but it did not
forward `supportsOptimizationToSubcolumns`, `supportedPrewhereColumns` or
`canMoveConditionsToPrewhere`, so it fell back to the `IStorage` defaults that
advertise capabilities the delegate (and the plain `URL` engine) deliberately
reject:

- `IStorage::supportsOptimizationToSubcolumns` defaults to `supportsSubcolumns`
  (true for `File`/object storage), so `FunctionToSubcolumnsPass` would rewrite
  functions to subcolumn reads for `ENGINE = URL('file://...')`, while direct
  `StorageFile` and plain `StorageURL` return `false`.
- `IStorage::supportedPrewhereColumns` defaults to `std::nullopt` (unrestricted)
  and `IStorage::canMoveConditionsToPrewhere` to `supportsPrewhere`, so explicit
  `PREWHERE` or auto-moved conditions could target default-expression or
  hive-partition columns that `StorageFile`, `StorageObjectStorage` and plain
  `StorageURL` exclude from `supportedPrewhereColumns`.

Forward all three methods to the delegate, mirroring `StorageAlias`. Add
`04402_url_engine_dispatch_planner_capabilities` asserting that
`ENGINE = URL('file://...')` does not get the subcolumn rewrite (with a
`MergeTree` control that does) and rejects `PREWHERE` on a default-expression
column while allowing it on a plain column.

Addresses the automated review on ClickHouse#106093

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-dispatch

Unify File/object-storage engines under the URL engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature 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.

3 participants