Repository navigation
Support wildcard for url table function - #95181
Conversation
|
Workflow [PR], commit [35d1bda] Summary: ✅
AI ReviewSummaryThe current PR head has addressed the previously raised implementation issues I rechecked around path normalization, query/fragment inheritance, PR MetadataThe 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 Also consider adding Findings
TestsThe Praktika CI report helper found 1 report with 170 total jobs, 0 failed. I did not run local tests. Final VerdictStatus: Minimum required action: avoid persisting |
337b5dd to
6bc0b05
Compare
…ered as the order in index page
…d glob pattern for url query parameters
…d url processing to StorageURL and web object storage
…d start resolver container
6bc0b05 to
cfa9c61
Compare
There was a problem hiding this comment.
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()/URLengine reads with listable*globs throughStorageObjectStoragebacked by a newWebObjectStorage+MetadataStorageFromIndexPages. - Add server setting
max_http_index_page_sizeand integration tests covering listing, ordering, size limits, query/fragment strictness, and propagated request headers. - Add
_headersvirtual 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. |
# 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]>
ff8bcd2 to
ae36398
Compare
|
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! |
|
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]>
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]>
|
Picked up the branch and pushed Merged Fixed the two
The remaining non-green checks are all known, unrelated flakes (this PR touches only URL/web object storage, not AST formatting / type casting / threading):
|
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]>
|
Addressed the two outstanding AI-Review findings (pushed 1. Unknown-size page cache on the disk path ( 2. Native protocol spec ( 3. Build (debug) and the |
|
Updated the PR description to match the current matching semantics: wildcards are matched against the URL path component — the This addresses the documentation half of the AI-review "Request changes" verdict. The other half — not persisting |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 1651/2065 (79.95%) · Uncovered code |
…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( |
There was a problem hiding this comment.
@groeneai are there tests where the glob matches no files?
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]>
…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]>
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]>
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]>
… `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]>
Support wildcard for `url` table function
…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]>
… 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]>
Closes: #94035
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enable wildcard expansion for
url()and theURLengine 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
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, defaultfalse): 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
?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.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
26.7.1.295(included in26.7and later)