Repository navigation
Allow overriding the HTTP method for SELECT through the url table function and URL engine - #114665
valerypetrov wants to merge 66 commits into
Conversation
…ction and URL engine `http_method='POST'` — as a key-value argument of the `url` table function and the `URL` engine, or through the `http_method`/`method` named collection keys — now applies to `SELECT` queries: reads use `POST` instead of the default `GET`, for servers that accept only `POST`. `PUT` keeps its write-only meaning (a `SELECT` through a configuration with `http_method='PUT'` still uses `GET`). Schema inference follows the configured method. The key-value argument is rejected when the URL scheme dispatches to another backend (file://, s3://, ...), mirroring `headers(...)`. Issue: ClickHouse#62352 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
|
Workflow [PR], commit [f7c4f59] Summary: ❌
AI ReviewSummaryThe PR adds explicit The method-qualified cache-source representation is handled consistently by schema lookup/insertion, row-count lookup/insertion, and credential masking in Final VerdictStatus: ✅ Approve |
The argument-scan loop in evalArgsAndCollectHeaders no longer needs a real iterator after the key-value-argument change, so clang-tidy's modernize-loop-convert now applies: convert it to a range-based loop. In the new test, use currentDatabase() instead of the interpolated database name in the system.query_log condition, as the style check requires. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
…e wildcards Addresses the two review blockers: The URL schema cache (schemas and row counts) now includes the effective HTTP read method in its key: POST-derived entries are stored under `POST:<url>`, while GET keeps the plain URL, preserving existing entries and the user-visible `source` in system.schema_inference_cache. The cache-validation request (tryGetLastModificationTime) follows the configured method instead of always probing with GET, which failed against POST-only servers. `http_method='POST'` combined with `*`/`**` wildcards expanded from HTTP index pages is now rejected explicitly — in the url table function, its schema inference, and the URL engine — instead of silently falling back to probing the literal `*` URL. PUT keeps the pre-existing behavior, as its reads use plain GET. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
A `SELECT` through a configuration with `http_method='PUT'` is documented to behave exactly like the default `GET` path, so the wildcard/object-storage gates now follow `chooseReadMethod(...)` instead of testing whether `http_method` is empty: PUT-configured reads take the index-page listing path like GET (in the url table function, its schema inference, and the URL engine), while POST is still rejected explicitly. `urlCluster` rejects `*`/`**` index-page wildcards unconditionally now: it can never list index pages, so a configured `http_method` must not bypass the NOT_IMPLEMENTED rejection. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes11 object files changed (+86.43 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units22 translation units recompiled, 148 s compile time in total, 22 of them have a recent master baseline. |
…nesty Wildcard/index-page gating: the URL engine keeps any configured http_method on the plain literal-URL backend (the engine serves writes, PUT exists only for writes, and the web object-storage backend cannot write), rejecting POST+wildcard combinations only at CREATE strictness so ATTACH/RESTORE of pre-existing tables keeps loading; the read-only url() table function still routes PUT-configured SELECTs to the listing path. INSERT-side inference can no longer probe the literal `*` URL with POST: both the explicit getActualTableStructure path and the VALUES path (whose inference runs in the storage constructor via an empty columns list) are rejected, while explicit-structure INSERT writes stay allowed. urlCluster rejects index-page wildcards regardless of the configured method, and its signature/docs now mention the argument. POST-read transport: HEAD-derived metadata is not used for POST reads at all - getFileInfo returns empty for non-GET methods (a HEAD describes the GET representation; HEAD-executing endpoints would run the workload twice), tryGetLastModificationTime returns null for non-GET honestly instead of carrying an ineffective method parameter, seekability is gated to GET mirroring supportsReadAt, and a ranged retry answered with a plain 200 on a non-GET read fails immediately instead of re-executing the endpoint http_max_tries times. Also: StorageURLWithFailover threads headers/http_method through its constructor, StorageURLSource asserts the effective read method invariant, the duplicate-argument error names both the table function and the engine, and named-collection key precedence is documented. Tests: engine PUT+wildcard CREATE (plain backend, DDL round-trip), INSERT auto-structure rejection, urlCluster rejection with a configured method, combined/reordered key-value arguments, the method= alias, analyzer alias capture, wire-verified INSERT POST, DETACH/ATTACH round-trip, and corrected schema-cache case comments. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Two follow-ups to the ATTACH-safety review findings: The scheme-dispatch rejection of a configured `http_method` (file://, s3://, ...) now fires only at CREATE strictness: named collections have been accepting the key regardless of the URL scheme, so pre-existing tables whose collection resolves to a non-HTTP scheme keep attaching after upgrade, with the delegated backend ignoring the key as before. Conversely, a table that loads with POST + `*`/`**` index-page wildcards (possible when a named collection is edited after the table was created) no longer probes the literal `*` URL with POST at read time: the read path enforces the same BAD_ARGUMENTS rejection as CREATE, so relaxed loading cannot turn into silently reading the wrong resource. The test covers the full scenario: collection edited to a wildcard URL after CREATE, DETACH/ATTACH loading fine, and the subsequent SELECT failing loudly before any connection. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Named collections accepted `http_method`/`method` for any URL scheme
before this feature made the key apply to reads, so `url(nc)` with a
collection like {url='s3://...', http_method='PUT'} must keep delegating
to the backend with the key ignored — mirroring the URL engine's
non-CREATE loads. The inline key-value argument is new syntax with no
legacy usage and is still rejected before dispatch.
NOTE: pushed without a local build at the user's request (the build host
is saturated); covered by a test asserting the collection form delegates
(no http_method guard error) while the inline form still rejects.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Two precision fixes to the review's compatibility carve-outs: The url() scheme-dispatch exemption now applies only to an `http_method` value STORED in a named collection (checked via isQueryOverridden): a query-time override like url(nc, http_method='POST') is new syntax and is rejected exactly like the inline argument. The URL engine guards (non-HTTP-scheme rejection and POST + index-page wildcard rejection) now use the standard fresh-definition predicate — `mode <= CREATE || (mode == ATTACH && !attach_short_syntax)` — matching StorageKafkaUtils/registerStorageMergeTree, so a full-definition `ATTACH TABLE ... ENGINE = URL(...)` (which is new user input) cannot bypass them, while short-syntax attach, server startup, and restore keep the relaxed loading. Tests: url(nc, http_method='POST') on a file:// collection rejects; a full-definition ATTACH with http_method on a file:// URL rejects. NOTE: pushed without a local build at the user's request; CI validates. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Atomic databases reject a full-definition ATTACH without an explicit UUID before the engine guard can fire, so the case produced a different error in CI. The UUID form (used by other stateless tests) reaches the guard; it throws before anything is registered under that UUID. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
…uard
A value STORED in a named collection is legacy configuration for any URL
scheme, so a fresh `CREATE TABLE ... ENGINE = URL(nc)` over a collection
like {url='file:///...', http_method='PUT'} must keep delegating with
the key ignored, matching the url() table function. The stored-vs-
override distinction now lives as a flag on StorageURL::Configuration,
set in processNamedCollectionResult from isQueryOverridden, and the
table function reuses it instead of deriving its own.
Test: fresh engine CREATE over a file:// collection with a stored
http_method delegates (no http_method guard error).
NOTE: pushed without a local build at the user's request; CI validates.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
The dispatch path re-checks TABLE_ENGINE for the target backend so a user granted only `TABLE ENGINE ON URL` cannot reach File/S3/Azure/HDFS through the URL wrapper. That re-check ran only on CREATE, so a full-definition ATTACH — which is new user input — bypassed it. Extend the check with the same full-definition-ATTACH clause as the other guards; short-syntax attach, restore, startup loading, and SECONDARY_CREATE (replicated DDL replay, already authorized on the initiator) stay unchecked as before. The test attaches a File-dispatching URL table as a user granted URL but not File, expecting ACCESS_DENIED. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Named collections are server-global, and the flaky check executes a changed test repeatedly and concurrently, so the fixed collection names collided with themselves (NAMED_COLLECTION_ALREADY_EXISTS). Derive the names from the test database like the query-log tags, and always drop before creating. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Fixed UUID literals collide when the flaky check runs the test concurrently: one instance registers the mapping and its twin fails with a duplicate-UUID error instead of the asserted rejection. Generate both UUIDs at runtime, like the collection names and query-log tags. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
Callers overload that flag as "structure is required" rather than "this is an INSERT" — InterpreterDescribeQuery passes true for DESCRIBE — so the recently added condition sent DESCRIBE of a GET wildcard URL to the literal-URL probe instead of the listing path (caught by test_storage_url::test_url_wildcard_schema_inference under the old analyzer). Restore the listing condition to effective-GET plus listable globs; the POST rejection above still covers the case that actually required protection. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
A POST read cut short is retried with a range, and a server answering 200 cannot be resumed. That error copied the response reason phrase verbatim, so a reflected signature or bearer token reached the client, the server log and system.query_log. It is now scrubbed like the neighbouring range errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A named collection's http_method/method key, stored or passed with the call, was the write method before this PR, and reads always used GET. Reading it as the read method too made an unchanged url(nc) or ENGINE = URL(nc) switch to POST after an upgrade, which can create data on an API where POST creates resources. Only the inline http_method argument, which is new, now changes reads; a collection's method behaves as before, also around index-page wildcards. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A table over a named collection with a method and a wildcard URL is no longer rejected when read, so the read now tries to connect to `localhost:1` and retries with backoff: about 140 seconds each, which made the test time out in the fast test. One try is enough to show that the method error is gone; the test now takes 3 seconds instead of 281 locally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hod-62352 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…INSERTs `IStorageURLBase::write` defaulted the shared storage member `http_method` to POST on every call, without synchronisation. Two INSERT sinks opened at the same time on one `ENGINE = URL` table created without an explicit method (for example the local shard jobs of a foreground `Distributed` INSERT) read and wrote the same `std::string` concurrently, which ThreadSanitizer reports and, with `halt_on_error=1`, aborts the server on (La Casa Del Dolor (amd_tsan) on master b59eadf). Compute the method into a local instead. The member is now written only by the constructor, and both sinks still get POST unless a method was configured. The hunk is identical to the one in ClickHouse#114665, so the two merge cleanly in either order. The test runs a foreground Distributed INSERT into five local shards over a fresh URL table per iteration: before the fix the TSan server aborted in 8 of 8 runs, after it 25 of 25 runs passed with no report. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new errors for http_method with index-page wildcards and with scheme dispatch printed the resolved URL as is, so a password or a presigned signature (also one taken from url_base) reached the exception text, the server log and system.query_log. Mask a copy of the URL before formatting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hod-62352 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The http_method validation errors masked the URL password and presigned signature but still printed ordinary credential parameters such as access_token. They now also go through maskSensitiveQueryParametersInURI. A POST read has no HEAD to ask, so its buffer reported empty metadata and the source took `_size` and `_time` before the POST started: they came out NULL and a `_time` filter dropped every row unless engine_url_skip_empty_files was set. The source now starts a POST before taking the metadata, and the buffer keeps the POST response's metadata even without Content-Length. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A URL pattern can hold several authorities, as in brace or failover patterns, and the single-URI masker hid at most the first password. These errors only reject a method combination, so they no longer print the URL at all. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hod-62352 Bring the branch up to date with master. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/TableFunctions/TableFunctionURL.cpp
clang-tidy's modernize-use-nodiscard is an error on master now, and this const getter added by the branch was failing the tidy builds in every translation unit that includes StorageURL.h. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…hod-62352 # Conflicts: # src/Storages/StorageURL.cpp # src/Storages/StorageURLCluster.cpp
…hod-62352 # Conflicts: # src/Storages/StorageURL.cpp # src/Storages/StorageURLCluster.cpp # src/TableFunctions/TableFunctionURL.cpp
AI review of a later commit does not approve the PR, see the AI Review comment.
The `http_method = <expr>` argument was evaluated and validated, but the original expression stayed in the key-value node. `ENGINE = URL` keeps that node in the stored table definition, so DETACH/ATTACH and server restart evaluated the expression again under other settings: it could fail with "HTTP method cannot be empty" or silently switch reads from POST to GET. The urlCluster argument rewrite also forwarded the expression for the workers to evaluate again. Replace the right-hand side of the node with the validated literal, so the stored definition and the query sent to the workers carry the method itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #62352
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
http_method='POST'as a key-value argument of theurltable function and theURLtable engine now applies toSELECTqueries: reads usePOSTinstead of the defaultGET, for servers that accept onlyPOST. Schema inference follows the configured method.PUTkeeps its write-only meaning: aSELECTwithhttp_method='PUT'still usesGET. Thehttp_method/methodkey of a named collection still applies to writes only, as before.Implementation notes
IStorageURLBase::getReadMethod()now returnsPOSTwhen the configuredhttp_methodisPOST.PUTstill applies to writes only (pre-signed upload URLs, Allow PUT instead of POST for url() writes #44326), andINSERTbehavior is unchanged:POSTby default,PUTwhen configured.http_methodmember when defaulting toPOST— the storage instance is shared between queries, so persisting the write default would have flipped subsequent reads of the same table fromGETtoPOST(and raced concurrent reads).getTableStructureAndFormatFromDataand the URL read-buffer iterator) uses the same effective read method instead of hardcodedGET, for bothurl()/URLandurlCluster.http_method = '...'(ormethod = '...') key-value argument is parsed byStorageURL::evalArgsAndCollectHeadersalongsideheaders(...), kept in theCREATEAST (so it survivesSHOW CREATE TABLEand DETACH/ATTACH), validated to bePOST/PUT, and rejected when the URL scheme dispatches to another backend (file://,s3://, ...), mirroringheaders(...); a named collection'shttp_methodkey is still ignored there, as before.skipAnalysisForArguments), likeheaders(...).urltable function and theURLengine is updated.The new stateless test
04869_url_select_http_methodasserts the method actually used on the wire viasystem.query_log.http_method: defaultGET,POSToverride for both the data and the schema-inference requests,PUT-configuredSELECTstaying onGET, theURLengine path, rejection of unsupported methods, and persistence of the argument in the table DDL.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/114665]