Skip to content

Support wildcard for url table function - #95181

Merged
alexey-milovidov merged 159 commits into
ClickHouse:masterfrom
niyue:feat/url-wildcard
Jun 30, 2026
Merged

alexey-milovidov merged 159 commits into
ClickHouse:masterfrom
niyue:feat/url-wildcard

Conversation

@niyue

@niyue niyue commented Jan 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #94035

Changelog category (leave one):

  • New Feature

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

Enable wildcard expansion for url() and the URL engine by listing HTTP index pages (HTML or plaintext directory listings) and extracting matching URLs. Wildcards are matched against the URL path component, with limits on the index page size and on the number of directories read.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Motivation
Allow url() and the URL engine to read from HTTP directory listings (HTML or plaintext) so users can query datasets hosted on standard web indexes without a listing API.

Parameters

  • allow_experimental_url_wildcard_from_index_pages (setting, default false): enables this experimental feature.
  • max_http_index_page_size (server setting, default 10MB): maximum size of an HTTP index page body; exceeding it raises an error.
  • url_wildcard_max_directories_to_read (setting, default 100000): maximum number of directories traversed while expanding URL wildcards from index pages.

Behavior notes

  • Index pages are fetched with HTTP GET and URLs are extracted from the response body.
  • Relative URLs are resolved against the index page URL.
  • Wildcard matching is applied to the URL path component; the ? query string and # fragment are not part of the match. If a listed URL already contains a query string or fragment, it takes precedence over the ones from the source URL; otherwise the query string and fragment from the source URL are used.
  • Empty listings are allowed; HTTP errors (e.g. 404) for index pages raise exceptions.

Example use

SELECT count()
FROM url('https://dumps.wikimedia.org/other/pageviews/2025/pageviews*.gz', 'TSV');

SELECT sum(x)
FROM url('https://downloads.apache.org/kafka/**/kafka-*.tgz', 'TSV', 'x UInt64');

Version info

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

@niyue niyue changed the title Feat/url wildcard Support wildcard for url table function Jan 26, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jan 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jan 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [35d1bda]

Summary: ✅


AI Review

Summary

The current PR head has addressed the previously raised implementation issues I rechecked around path normalization, query/fragment inheritance, _headers, read_source_index, unknown sizes/times, redirect handling, urlCluster, cache identity, and the Native protocol spec update. I found no new non-duplicative inline findings to post in this run.

PR Metadata

The PR body/changelog is now stale. It still says matching is "strict" and that the glob matches the full URL including query/fragment, but the current implementation and docs match wildcards against the URL path and then preserve or override query/fragment values. Suggested changelog text:

Enable experimental wildcard expansion for url and the URL engine by listing HTTP index pages and extracting links, with index-page size and recursive directory traversal limits.

Also consider adding allow_experimental_url_wildcard_from_index_pages and url_wildcard_max_directories_to_read to the PR body's behavior/parameter notes.

Findings

⚠️ Majors

  • [dismissed by author -- https://github.com/Support wildcard for url table function #95181#discussion_r3262963044] src/Storages/StorageURL.cpp:2087 still rewrites the mutable args.engine_args with skip_userinfo = false before constructing the web-backed URL engine. StorageObjectStorage::addInferredEngineArgsToCreateQuery only updates format/structure, so a table created with url_base = 'http://user:pass@host/...' and a relative wildcard URL can still persist the resolved user:pass@... URL into table metadata / SHOW CREATE TABLE. This was dismissed as out of scope, but it remains a user-visible credential exposure risk in the current code.
Tests

The Praktika CI report helper found 1 report with 170 total jobs, 0 failed. I did not run local tests.

Final Verdict

Status: ⚠️ Request changes

Minimum required action: avoid persisting url_base credentials when initializing the web-backed URL engine, and update the PR body/changelog so it matches the current path-only query/fragment semantics.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jan 26, 2026
@niyue
niyue force-pushed the feat/url-wildcard branch 3 times, most recently from 337b5dd to 6bc0b05 Compare February 2, 2026 10:57
@GrigoryPervakov GrigoryPervakov self-assigned this Feb 3, 2026

Copilot AI left a comment

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.

Pull request overview

Adds wildcard (* / **) expansion for url() / URL engine by treating HTTP directory listings as an object storage and parsing index pages to enumerate matching URLs (with a server-side max page size limit), plus exposes HTTP response headers via a virtual column.

Changes:

  • Route url() / URL engine reads with listable * globs through StorageObjectStorage backed by a new WebObjectStorage + MetadataStorageFromIndexPages.
  • Add server setting max_http_index_page_size and integration tests covering listing, ordering, size limits, query/fragment strictness, and propagated request headers.
  • Add _headers virtual column support for web reads by threading HTTP response headers through read buffers.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/integration/test_storage_url/test.py Adds integration coverage for wildcard expansion via HTTP index pages and virtual columns.
tests/integration/test_storage_url/index_pages_server.py Adds a mock HTTP server serving directory listings and test data.
src/TableFunctions/TableFunctionURL.cpp Switches wildcard url() reads to object-storage-backed web configuration when applicable.
src/Storages/StorageURL.h Declares helper for detecting listable globs in URL paths.
src/Storages/StorageURL.cpp Implements path-glob detector; routes URL engine to object storage for listable globs; minor iterator rename.
src/Storages/ObjectStorage/Web/Configuration.h Introduces web object storage configuration for URL-backed object storage.
src/Storages/ObjectStorage/Web/Configuration.cpp Implements parsing/validation and settings mapping for the web configuration.
src/Storages/ObjectStorage/StorageObjectStorageSource.h Adds plumbing to access the underlying read buffer for metadata extraction.
src/Storages/ObjectStorage/StorageObjectStorageSource.cpp Implements _headers virtual column population from HTTP response metadata.
src/Storages/ObjectStorage/StorageObjectStorage.cpp Adds _headers virtual column for web type; adds schema-cache branch for “web”.
src/Storages/MergeTree/MergeTreeData.cpp Disables ALTER-on-disk for the new WebIndex metadata storage type.
src/IO/ReadWriteBufferFromHTTP.h Lets HTTP read buffer expose metadata via IReadBufferMetadataProvider.
src/IO/ReadWriteBufferFromHTTP.cpp Implements metadata getter returning response headers.
src/IO/ReadBufferFromFileDecorator.h Makes decorator forward read-buffer metadata.
src/IO/ReadBufferFromFileDecorator.cpp Implements metadata forwarding to wrapped buffer.
src/IO/IReadBufferMetadataProvider.h Adds a small interface to retrieve buffer metadata (e.g., HTTP headers).
src/IO/CachedInMemoryReadBufferFromFile.h Makes cache buffer forward read-buffer metadata.
src/IO/CachedInMemoryReadBufferFromFile.cpp Implements metadata forwarding to underlying buffer.
src/Disks/IO/ReadBufferFromWebServer.h Adds request headers pass-through and metadata accessors for response headers.
src/Disks/IO/ReadBufferFromWebServer.cpp Wires request headers into HTTP builder; exposes response headers as metadata.
src/Disks/IO/CachedOnDiskReadBufferFromFile.h Makes disk cache buffer forward read-buffer metadata.
src/Disks/IO/CachedOnDiskReadBufferFromFile.cpp Implements metadata forwarding across cache/remote/local readers.
src/Disks/IO/AsynchronousBoundedReadBuffer.h Makes async bounded buffer forward read-buffer metadata.
src/Disks/IO/AsynchronousBoundedReadBuffer.cpp Implements metadata forwarding to wrapped impl.
src/Disks/DiskType.h Adds MetadataStorageType::WebIndex.
src/Disks/DiskType.cpp Adds web_index string mapping to WebIndex.
src/Disks/DiskObjectStorage/ObjectStorages/Web/WebObjectStorage.h Extends web object storage to support listing and request headers.
src/Disks/DiskObjectStorage/ObjectStorages/Web/WebObjectStorage.cpp Reworks web object storage to use index-page-based metadata listing and object metadata probing.
src/Disks/DiskObjectStorage/ObjectStorages/ObjectStorageFactory.cpp Updates factory construction for new WebObjectStorage signature.
src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromStaticFilesWebServer.h Moves file-cache logic into the metadata storage (no longer in WebObjectStorage).
src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromStaticFilesWebServer.cpp Updates static-web metadata storage to use moved cache and pass request headers.
src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromIndexPages.h Introduces metadata storage that lists directories by parsing HTTP index pages.
src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromIndexPages.cpp Implements index-page fetch/size limit, HTML extraction, and strict URL filtering.
src/Disks/DiskObjectStorage/MetadataStorages/MetadataStorageFactory.cpp Registers the new web_index metadata storage type.
src/Disks/DiskObjectStorage/DiskObjectStorage.cpp Marks WebIndex metadata storage as shared-compatible.
src/Core/ServerSettings.cpp Adds server setting max_http_index_page_size.
src/CMakeLists.txt Adds build wiring for the new Storages/ObjectStorage/Web sources.
docs/en/sql-reference/table-functions/url.md Documents wildcard expansion via HTTP index pages and the new server setting.

Comment thread src/TableFunctions/TableFunctionURL.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Feb 22, 2026
alexey-milovidov and others added 2 commits February 22, 2026 22:28
# Conflicts:
#	src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromStaticFilesWebServer.cpp
#	src/Disks/DiskObjectStorage/MetadataStorages/Web/MetadataStorageFromStaticFilesWebServer.h
#	src/Storages/ObjectStorage/StorageObjectStorageSource.cpp
#	src/Storages/StorageURL.cpp
- Replace manual `new ASTLiteral`/`new ASTFunction`/`new ASTExpressionList` with
  `make_intrusive<>` as requested by reviewer
- Fix `createObjectStorage` signature to match base class (3 params with
  `CredentialsConfigurationCallback`)
- Fix `CachedOnDiskReadBufferFromFile::getMetadata` to use correct member names
  (`state->buf`, `info.remote_file_reader` instead of non-existent members)
- Fix `MetadataStorageFactory` registration to match new `Creator` signature
  with `ClusterConfigurationPtr` and `ObjectStorageRouterPtr`
- Fix include path for `StaticDirectoryIterator.h` (moved to MetadataStorages)
- Make `href_regex` static const to avoid recompilation on each call
- Use `log` member instead of `getLogger("DiskWeb")` in `WebObjectStorage::exists`
- Use `contains` instead of `find != npos` (clang-tidy)
- Fix grammar "supports" → "support" in signatures
- Fix `?` wildcard note in URL docs (cannot be used in URL path)
- Suppress test server logging, remove unused import

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov alexey-milovidov removed the manual approve Manual approve required to run CI label Feb 22, 2026
@niyue

niyue commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @alexey-milovidov,

I happened to take a two-week break during Chinese New Year and wasn’t able to follow up on the review comments in a timely manner. I just returned from the holiday today and noticed that you’ve created a new branch with the comments addressed.

How would you like to proceed? Should I continue working on it, or would you prefer to take it over? I’m happy to proceed accordingly, please let me know your preference. Thanks!

@alexey-milovidov

Copy link
Copy Markdown
Member

Thank you! The current review comments are addressed, and we will need the next round of review to finish.

Resolve conflict in `StorageObjectStorageSource::generate` by keeping
both the PR's `http_response_headers_initialized` reset and master's
`total_files_read` increment.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
niyue and others added 7 commits June 28, 2026 21:19
The test read the create statement with `node.query("SHOW CREATE TABLE ...")`,
which is returned in the default `TabSeparated` format. `TabSeparated` escapes
single quotes (via `writeEscapedString` -> `writeAnyEscapedString<'\''>`), so the
result contained `\'TSV\', \'none\'` and the assertion `"'TSV', 'none'" in
create_query` never matched. The feature itself works: the inferred `TSV` format
and the `none` compression argument are persisted correctly.

Use `SHOW CREATE TABLE ... FORMAT TSVRaw` so the statement is returned verbatim
and the positional arguments can be matched as written.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The test queried two comma-separated full URLs with *different paths*
(`.../page_cache_shard0/part*.tsv,.../page_cache_shard1/part*.tsv`). The URL
index-page wildcard feature represents shards as a single shared path (`path.path`)
that differs only by authority/query (`StorageWebConfiguration::setNamespaceFromURL`
only expands shards in the authority part). A top-level comma between two
different-path URLs is therefore absorbed into the first shard's path, producing a
single shard whose glob is `part*.tsv,http://.../part*.tsv` that matches nothing, so
the query silently read 0 rows (`files_read=0`) instead of 303.

Besides being unsupported, the different-path form would not have isolated source
identity anyway: distinct object paths already produce distinct page-cache keys, so
the test would pass with or without the fix.

Convert the test to the supported same-path/different-source form
(`.../page_cache_identity/part*.tsv?shard={0,1}`, mirroring
`test_url_wildcard_archive_metadata_uses_shard_identity`): both shards list the same
`part.tsv` object with the same ETag but different contents, so the page cache must
use the web source identity to avoid a cross-shard cache collision. Verified locally
against a fresh build and the mock server: the query returns 303 with
`use_page_cache_for_object_storage=1`.

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

Copy link
Copy Markdown
Member

Picked up the branch and pushed 15563095243..966bd32e4a9.

Merged master (branch was 570 commits behind) — conflict-free. The two new settings stay in the 26.7 SettingsChangesHistory block (dev version is still 26.7.1), so the 02995_new_settings_history Fast test stays green.

Fixed the two test_storage_url failures that were red on the previous run (both are test_storage_url/test.py tests added on the 28th; they were the only PR-related failures). I built ClickHouse from this branch locally and reproduced/verified each against the mock index-page server.

  1. test_url_engine_persists_inferred_format_with_compression_argument — test-only bug. The test read the create statement with node.query("SHOW CREATE TABLE …"), which is returned in the default TabSeparated format. TabSeparated escapes single quotes (writeEscapedString → writeAnyEscapedString<'\''>), so the result actually contained \'TSV\', \'none\' and the assertion "'TSV', 'none'" in create_query never matched. The feature is correct — the inferred TSV format and the none compression argument are persisted. Fix: use SHOW CREATE TABLE … FORMAT TSVRaw so the statement is returned verbatim.

  2. test_url_wildcard_page_cache_uses_web_source_identity — the test queried two comma-separated full URLs with different paths (…/page_cache_shard0/part*.tsv,…/page_cache_shard1/part*.tsv). The index-page wildcard feature represents shards as a single shared path.path that differs only by authority/query (StorageWebConfiguration::setNamespaceFromURL only expands shards in the authority part). A top-level comma between two different-path URLs is therefore folded into the first shard's path, producing a single shard whose glob is part*.tsv,http://…/part*.tsv — which matches nothing, so the query silently read 0 rows (files_read=0) instead of 303. Besides being unsupported, the different-path form would not isolate source identity anyway (distinct object paths already produce distinct cache keys). I converted it to the supported same-path / different-source form (…/page_cache_identity/part*.tsv?shard={0,1}, mirroring test_url_wildcard_archive_metadata_uses_shard_identity): both shards list the same part.tsv with the same ETag but different contents, so the page cache must use the web source identity to avoid a cross-shard collision. Verified: returns 303 with use_page_cache_for_object_storage=1.

Note for @niyue: silently returning 0 rows for comma-separated different-path URLs (e.g. url('http://h/a/*.tsv,http://h/b/*.tsv')) under the wildcard feature is a bit of a footgun — similar to the |-in-path case that is already rejected with an explicit error. You may want to either reject it explicitly or support it in a follow-up; I kept this change test-only.

The remaining non-green checks are all known, unrelated flakes (this PR touches only URL/web object storage, not AST formatting / type casting / threading):

Comment thread src/Core/ProtocolDefines.h Resolved
alexey-milovidov and others added 2 commits June 30, 2026 08:46
Reading an object served without `Content-Length` through the
`DiskObjectStorage` read path with `use_page_cache_for_disks_without_file_cache = 1`
threw `UNKNOWN_FILE_SIZE`. `DiskObjectStorage::prepareRead` enables the in-memory
page cache based only on the file-cache / setting state, without checking object
size, and `CachedInMemoryReadBufferFromFile` reads `getFileSize` up front and
addresses the file by absolute offset, which is impossible for an object whose
size arrives as `StoredObject::UnknownSize` (e.g. a `web_index` disk entry whose
origin sent no `Content-Length`). The object storage source already disables the
page cache for unknown-size objects, but the disk path did not.

Gate the memory-cache stage on a single `usesMemoryCache` predicate that, like
the existing `canUseFilesystemCache` guard, returns false when any object has
unknown size. The source stages compute `use_external_buffer` from the same
predicate, so skipping the stage does not leave the inner reader in
external-buffer mode without a driver (which otherwise recurses infinitely in
`ReadBuffer::next` on a zero-size external buffer).

Add a `ReadPipeline.MemoryCacheSkipsUnknownSizeObject` gtest covering the
gather + unknown-size + page-cache path, mirroring
`FilesystemCacheSkipsUnknownSizeObject`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The PR bumps `DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION` to `7` and serializes an
optional `read_source_index` in the inter-server `ReadTaskResponse` payload. Note
the current cluster-function protocol version in the spec, mirroring how the
analogous `parallel_replicas_protocol_version` records its current value. The
`ReadTaskResponse` body itself stays unspecified — like the other cluster/parallel
read-task packets, it is inter-server only and external clients decode and ignore
`cluster_function_protocol_version`.

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

Copy link
Copy Markdown
Member

Addressed the two outstanding AI-Review findings (pushed 966bd32..35d1bda):

1. Unknown-size page cache on the disk path (MetadataStorageFromIndexPages.cpp / ReadPipeline) — commit f6209a8d58d. DiskObjectStorage::prepareRead enabled the in-memory page cache without checking object size, so a web_index disk entry served without Content-Length (StoredObject::UnknownSize) read with use_page_cache_for_disks_without_file_cache = 1 threw UNKNOWN_FILE_SIZE (the object storage source already guarded this, the disk path did not). The memory-cache stage is now gated on a single usesMemoryCache predicate that, like the existing canUseFilesystemCache guard, skips unknown-size objects; the same predicate drives use_external_buffer, so skipping the stage does not strand the inner reader in external-buffer mode. New gtest ReadPipeline.MemoryCacheSkipsUnknownSizeObject (gather + unknown size + page cache) fails without the fix and passes with it.

2. Native protocol spec (NativeProtocol.md) — commit 35d1bda96fb. Records the current cluster-function protocol version (7) and that 7 adds the optional read_source_index to the inter-server ReadTaskResponse payload, mirroring how parallel_replicas_protocol_version documents its current value. The ReadTaskResponse body stays unspecified, consistent with every other cluster/parallel read-task packet in the spec (all "not specified"; inter-server only).

3. ENGINE = URL credential persistence (StorageURL.cpp) — the inline thread was resolved earlier with the maintainer's decision that this is out of scope of this task, so I have not reintroduced it here. @alexey-milovidov, flagging that the AI verdict keeps re-raising it as a blocker — please confirm it should remain out of scope.

Build (debug) and the ReadPipeline.* unit tests pass locally. Fresh CI re-fired on the new commits.

@alexey-milovidov

Copy link
Copy Markdown
Member

Updated the PR description to match the current matching semantics: wildcards are matched against the URL path component — the ? query string and # fragment are not part of the match — which is exactly what the implementation (MetadataStorageFromIndexPages: getPathPrefixForMatching / getListingPrefixURLForMatching strip the query and fragment before matching) and the url.md docs already do. The previous "must match the full URL including query/fragment" wording was stale. I also listed the allow_experimental_url_wildcard_from_index_pages and url_wildcard_max_directories_to_read settings in the description.

This addresses the documentation half of the AI-review "Request changes" verdict. The other half — not persisting url_base credentials when initializing the web-backed URL engine — stays out of scope per the earlier maintainer decision (the inline thread was resolved on that basis).

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

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

Changed lines: Changed C/C++ lines covered: 1651/2065 (79.95%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov merged commit 6ea61f1 into ClickHouse:master Jun 30, 2026
173 of 174 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 30, 2026
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Jul 1, 2026
…he private repository

The open-source pull request ClickHouse#95181 added
`DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_READ_SOURCE_INDEX = 7`. In the
private repository version 7 is already taken by an Iceberg compaction feature,
so the same cluster-function protocol number ended up meaning two different
things in the two repositories. This must never happen, because a protocol
version number is exchanged on the wire and has to be interpreted identically
everywhere.

Reserve version 7 for the private Iceberg compaction feature (the constant
`DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_ICEBERG_COMPACTION` is defined
but unused in the open-source build) and renumber `read_source_index` to 8 so
the number space matches the private repository exactly. Every reference uses
the symbolic constant, so the only behavioral change is the advertised version
number. The protocol specification in `NativeProtocol.md` is updated to match.

Related: ClickHouse#95181

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
def test_url_wildcard_time_virtual_column_is_null_without_last_modified():
# The mock index server never sends a `Last-Modified` header, so the modification time is
# unknown and `_time` must be reported as NULL rather than the default epoch `1970-01-01`.
result = node1.query(

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 are there tests where the glob matches no files?

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.

and permission as well

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Address review feedback on PR ClickHouse#95181: in `registerStorageURL`, the
wildcard/object-storage branch was re-parsing `engine_args` directly in
`StorageObjectStorageConfiguration::initialize`, bypassing the URL
already resolved by `StorageURL::getConfiguration`.

With `SET url_base = 'http://host'` and
`ENGINE = URL('/data/**/part*.tsv', 'TSV')`, the wildcard detection saw
the resolved URL, but the object storage was initialized from the raw
relative URL.

Factor the URL-rewriting logic out of `addInferredEngineArgsToCreateQuery`
into a static `StorageURL::overrideURLInEngineArgs` helper and call it
on the wildcard branch with `skip_userinfo=false` (the object storage
configuration is not persisted to AST, so credentials carried from
`url_base` should be preserved).

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

`test_url_wildcard_preserves_failover_options` and
`test_url_engine_wildcard_preserves_failover_options` crashed the
sanitizer builds (ASan/UBSan, TSan, MSan) with
`Logical error: 'reader.buffer().begin() == request.buf'` at
`ThreadPoolRemoteFSReader::execute`.

Small failover objects are read through the async path
(`AsynchronousBoundedReadBuffer` -> `ThreadPoolRemoteFSReader`,
enabled by `remote_filesystem_read_prefetch` for objects below
`max_download_buffer_size`). That path reads into an external buffer
regardless of the number of failover URLs and asserts that the wrapped
reader honors it (`reader.buffer().begin() == request.buf`).

`WebObjectStorage::readObject` forced `use_external_buffer = false`
whenever `urls.size() > 1` (failover index-page wildcards), so
`ReadBufferFromWebServer::nextImpl` published `impl->buffer()` (its own
memory) as the working buffer instead of the external `request.buf`,
violating the async reader's contract.

Honor `remote_read_buffer_use_external_buffer` for failover objects too.
External-buffer reads require `delay_initialization = true`, which defers
the HTTP request and makes it impossible to detect a failing failover
option in `initialize`, so select a working URL first with a throwaway,
eagerly initialized connectivity probe and skip failing options.

Verified locally: the four `test_storage_url` failover tests and the full
`test_storage_url/test.py` suite (44 tests) pass with no contract
violation.

CI report:
ClickHouse#95181

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
After merging master, the development version was bumped to `26.6`, so the
`02995_new_settings_history` test now checks that settings introduced after
`26.5` are recorded in the `26.6` block of `SettingsChangesHistory.cpp`. The
new settings `allow_experimental_url_wildcard_from_index_pages` and
`url_wildcard_max_directories_to_read` were still registered under `26.5`,
which no longer satisfies the check, causing:

    PLEASE ADD THE NEW SETTING TO SettingsChangesHistory.cpp: allow_experimental_url_wildcard_from_index_pages WAS ADDED
    PLEASE ADD THE NEW SETTING TO SettingsChangesHistory.cpp: url_wildcard_max_directories_to_read WAS ADDED

Move both entries into the `26.6` block.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=95181&sha=7d6ee5b6d9a2345a73024ee57062ea86fbcc91d0&name_0=PR
PR: ClickHouse#95181

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
A dynamic `web` disk created inside a query (e.g. `disk(type = web, ...)` in
`03355_mergetree_table_disk`) stays in the disks map after the query finishes,
but `WebObjectStorage` stored the creation-time query context. Any later disk
access from another query (e.g. `existsDirectory` from
`InterpreterCreateQuery::clearTransactionMetadata`) then failed with the
logical error `Context has expired` in
`MetadataStorageFromStaticFilesWebServer::loadFiles`, killing the server in
sanitizer builds and causing the `Server died` failures across stateless CI
jobs.

Pin the global context as on master; per-request settings still come from the
current query context via `getRequestContext`.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=95181&sha=b637a07282a401e9a3c207483ad452d0dadb32ef&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29
PR: ClickHouse#95181

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
… `url` wildcards

For web listings, predicate filtering during listing evaluated `_path`
against a normalized path-only value, while rows later expose `_path` built
by `getUniqueStoragePathIdentifier` (with the namespace and the URL
query/fragment). A predicate written against the visible `_path` could
therefore drop a file before it was read.

Pass the same value that rows expose to the listing-time filter, and supply
the query-stripped file name (`getFileName`) separately through a new
optional `file_names` argument of `filterByPathOrFile`, because for web
paths `_file` strips the URL query/fragment while `_path` keeps it.

Addresses the remaining review thread. Adds integration test
`test_url_wildcard_path_filter_uses_visible_path`.

PR: ClickHouse#95181

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Support wildcard for `url` table function
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…he private repository

The open-source pull request ClickHouse#95181 added
`DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_READ_SOURCE_INDEX = 7`. In the
private repository version 7 is already taken by an Iceberg compaction feature,
so the same cluster-function protocol number ended up meaning two different
things in the two repositories. This must never happen, because a protocol
version number is exchanged on the wire and has to be interpreted identically
everywhere.

Reserve version 7 for the private Iceberg compaction feature (the constant
`DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_ICEBERG_COMPACTION` is defined
but unused in the open-source build) and renumber `read_source_index` to 8 so
the number space matches the private repository exactly. Every reference uses
the symbolic constant, so the only behavioral change is the advertised version
number. The protocol specification in `NativeProtocol.md` is updated to match.

Related: ClickHouse#95181

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
PedroTadim added a commit that referenced this pull request Sep 15, 2026
… test

The backport moves `DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION` from 6 straight
to 9, defining 7 and 8 as constants so the number space matches `master`. But
26.6 has no code for version 8, `read_source_index` from #95181, which was
never backported. The version is negotiated as `min(worker, own)` and the task
response is written straight onto the connection, so in a mixed 26.6/26.7+
cluster both sides would agree on 9, one would write a field the other never
reads, and the stream would misalign in both directions.

Carry the version-8 field exactly as `master` does: this release never sets
`read_source_index`, so it writes an empty one, and a 26.6 worker that receives
a set one throws `UNKNOWN_PROTOCOL` instead of reading the wrong shards, which
is the same fail-closed rule `master` applies on the sending side.

Also restore `test_row_policy_over_csv`, which the cherry-pick dropped because
it appends after a test that does not exist on 26.6; the change it covers is
carried verbatim.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
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 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.

Support wildcards when querying URL

6 participants