Skip to content

Fix table functions reading the default database of other servers in distributed queries - #131589

Open
groeneai wants to merge 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/loop-dictionary-implicit-database-remote
Open

groeneai wants to merge 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/loop-dictionary-implicit-database-remote

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131316
Related: #118130

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed wrong results of table functions that read the current database, such as loop, dictionary, mergeTreeIndex, mergeTreeProjection and timeSeriesSamples, given a name without a database or '' in a subquery or JOIN of a distributed query (remote, Distributed tables, *Cluster table functions) or with parallel replicas: the other servers read it from their own default database instead, or failed when it did not exist there.

Description

On 26.10.2.103, from a database db where db.t holds 2, 3 and default.t holds 0, SELECT sum(number), count() FROM remote('127.0.0.2', numbers(4)) WHERE number IN (SELECT x FROM loop(t) LIMIT 2) returns 0 1 instead of 5 2. mergeTreeProjection('', t, p) and dictionary('d') behave the same; without such an object in default the query fails.

Root cause: such a call keeps that argument as written in the query tree, which is what other servers receive, and each resolves it in its own default database. #122985 and #131528 fixed merge with a binder of its own.

Change: the new ITableFunction::getQualifiedArguments returns the leading arguments with the database the call resolved written out (loop(t) is 'db', 't', dictionary('d') is 'db.d'), and QueryAnalyzer::resolveTableFunction substitutes them in one place, replacing the merge, loop and dictionary binders. With parallel replicas, timeSeriesTags(ts) and the other TimeSeries functions now reach the replicas written out too (#118130's first problem). It is implemented by merge, loop, dictionary, mergeTreeIndex, mergeTreeAnalyzeIndexes, mergeTreeCodecBlockCounts, mergeTreeTextIndex, mergeTreeProjection, the timeSeries* functions, timeSeriesSelector and prometheusQuery(Range); #128194 can use it instead of getTableArgument. As before, the table of remote / cluster is left to the remote server, and neither secondary queries nor the shard plan of serialize_query_plan are rebound.

Not changed: names inside a view query (#131770), and dictionary from a database whose name contains a dot.

Validation: the new tests fail on master and pass with the fix, 50/50 randomized.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131589]

groeneai and others added 2 commits November 14, 2026 10:16
… servers

`loop(t)` / `loop('', t)` and `dictionary('d')` without a database in a subquery
that a distributed query sends to other servers (an `IN` / `JOIN` subquery of
`remote`, a `Distributed` table, `*Cluster` table functions) were resolved by each
receiving server in its own default database instead of the current database of
the query: wrong rows when that database has an object of that name, otherwise
`UNKNOWN_TABLE` / `Dictionary (...) not found`. The analyzer kept the arguments as
written; only the local execution resolved the missing database.

Bind them at resolve time, like the one-argument `merge` (ClickHouse#122985) and `dictGet`:
`loop(t)` / `loop('', t)` become `loop('<current database>', 't')`, and the
`dictionary` name goes through `qualifyDictionaryNameWithDatabase`, the helper of
the `dictGet` binder. Secondary queries are left as sent, so the `IN` set names
hashed from the query tree agree between initiator and shard, also across versions.

The table of `remote` / `remoteSecure` / `cluster` / `clusterAllReplicas`, and
anything nested in it, is not bound: the remote server reads it in its own
database, as in releases. `buildQueryTreeDistributed` resolves it again as the
root of a separate query tree, so a `remote_target` flag (set for that root and
inherited through the argument loop) returns before every binder. This also undoes
the master-only binding of `remote('h', merge('^t'))` from ClickHouse#122985, which bound only
the rows (initiator's database) while the structure came from `DESCRIBE` on the
remote server (its default database).

The rewrites keep argument positions valid: `TableFunctionLoop` and
`TableFunctionDictionary` do not override `skipAnalysisForArguments`, and an
`IdentifierNode` argument never enters the skipped-argument list, so replacing the
one-identifier `loop` argument list leaves that list empty; the other two rewrites
are in place. A nested call binds its own node before the parent renders its AST,
so `loop(dictionary('d'))` carries the bound inner call.

With serialize_query_plan = 1 the plan of each shard is built on the initiator from
the printed query; such an analysis (any query printed from a resolved query tree)
skips the binders as well, since the query already went through them.

The dictionary name is left unqualified when the database name contains a dot: no
dictionary-name syntax can carry such a database, and writing it broke a local
`loop(dictionary(...))` from such a database. Tests: a database with a dot in its
name, and `remote('h', loop(t))`, whose table the remote server still resolves in
its own default database, also through tables created `AS remote('h', loop(t))` /
`AS remote('h', merge('^t'))` with their own columns, which skip the structure
lookup, with and without serialize_query_plan.

Related: ClickHouse#131316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the cross-file citation from the remote_target caller comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 3 findings over 3 rounds, the last one clean) plus my own cold reviews and the validation runs (1 more finding).

# Sev Finding Verdict Evidence / action
1 ❌ dictionary from a database whose name contains a dot was bound to an unparseable name; a local loop(dictionary('d')) from such a database broke too AGREE, fixed the name stays unqualified when the database name contains a dot; test from a <db>.dot database
2 ⚠️ no test line distinguished the remote_target early return AGREE, fixed remote('127.0.0.2', loop(t)) fails with UNKNOWN_TABLE from the remote's default database; red with the early return removed
3 ⚠️ the root remote_target (re-analysis in buildQueryTreeDistributed) had no test line AGREE, fixed tables created AS remote('h', loop(t)) / AS remote('h', merge('^t')) with their own columns skip the structure lookup; both red with the root flag flipped
4 ❌ with serialize_query_plan = 1 the shard's plan is built on the initiator from the printed query, so the binders bound the table of remote / cluster too AGREE, fixed that analysis (any query printed from a resolved query tree) skips the binders; the AS remote(...) table lines also run with SETTINGS serialize_query_plan = 1, red without it
5 💡 per-table-function binders accumulate in resolveTableFunction noted a generic table-function hook is #128194's territory
6 💡 about 40 code lines noted the remote_target plumbing is required by the binders

Also noticed, not raised: dictGet('d', ...) from a database whose name contains a dot fails the same way, already on 26.10 (other code); a local and a remote replica of a cluster(..., dictionary('d')) target read different databases, already on 26.10.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. From a database db with db.foo_a = 2, 3 and default.foo_a = 0: SELECT sum(number), count() FROM remote('127.0.0.2', numbers(4)) WHERE number IN (SELECT x FROM loop(foo_a) LIMIT 2) returns 0 1 on master, 26.10.2.103 and 26.3.33.24 every run (same for dictionary('d')); the new test fails on master every run with UNKNOWN_TABLE from 127.0.0.2.
b Root cause explained? The analyzer keeps loop(t) / dictionary('d') arguments as written, that query tree is what is sent to other servers, and each of them resolves the unqualified name in its own default database.
c Fix matches root cause? Yes. The name is bound to the current database where the query tree is built (resolve time), like the one-argument merge (#122985) and dictGet. No guard at the read site.
d Test intent preserved / new tests added? New test 05634_loop_dictionary_table_functions_implicit_database_remote: both functions and both spellings of each, IN over one and two shards, JOIN, nested loop(dictionary(...)), fileCluster, and remote('127.0.0.2', loop(t)) still failing with UNKNOWN_TABLE (its table is resolved by the remote server), also through tables created AS remote('127.0.0.2', loop(t)) / AS remote('127.0.0.2', merge('^t$')) with their own columns, read with default settings and with serialize_query_plan = 1 (UNKNOWN_TABLE / CANNOT_EXTRACT_TABLE_STRUCTURE, as in 26.10.2.103). New test 05634_loop_dictionary_table_functions_implicit_database_with_dot: the same from a database with a dot in its name.
e Both directions demonstrated? Yes. The 9 bound queries fail on master (UNKNOWN_TABLE, Dictionary (...) not found, or no row) and pass with the fix. The remote('127.0.0.2', loop(t)) line fails on a build without the remote-table early return (a row comes back). The four AS remote(...) table reads return a row on a build whose root re-analysis binds the table of remote, the two serialize_query_plan = 1 reads return a row on the previous version of this fix, and master returns a row on both merge table reads. The dotted-database test fails on master (remote loop(t)) and on the first version of this fix (local loop(dictionary('d'))), and passes now. 50/50 randomized runs, plus serialize_query_plan = 1 and parallel replicas.
f Fix is general across code paths? One binder for both functions, at the same place as the merge binder. The table of remote / cluster is skipped for every binder, including the re-analysis in buildQueryTreeDistributed, which also restores the release behaviour of remote('h', merge('^t')). joinGet('t', ...) and mergeTreeIndex('', t) are separate sites, not changed here.
g Fix generalizes across inputs (params/datatypes/wrappers)? loop(t), loop('', t), dictionary('d'), dictionary(d), loop(dictionary('d')) are bound; qualified forms (loop(db.t), loop('db', t), dictionary('db.d')) and XML dictionaries are left unchanged. From a database whose name contains a dot, loop is bound (the database is its own argument) and dictionary is left as written, since a dictionary name cannot carry such a database. Type wrappers do not apply (names, not values).
h Backward compatible? (maintainer-approved exception only) Yes. No setting. Secondary queries are left as sent, so a new initiator with an old shard returns correct rows, and an old initiator with a new shard keeps its old result; neither gives NOT_FOUND_COLUMN_IN_BLOCK. The table of remote / cluster returns the same rows and sent query text as 26.10.2.103.
i Invariants and contracts preserved? IN set names are hashed from the query tree: the binding happens before any hash is taken and secondary queries are not rebound, so initiator and shard agree. Argument positions stay valid (loop / dictionary skip no arguments), and the early return calls the same resolve as the normal path.

Session id: cron:clickhouse-impl-slot-6:20261114-095400

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [427c312]

Summary: ✅


AI Review

Summary

PR #131589 qualifies database-bearing table-function arguments through ITableFunction::getQualifiedArguments before queries reach other servers. Reviewed head 427c3126713061b43fcf06188971ff0304e9edd6, the complete diff, surrounding implementations, and all prior discussion. No new actionable findings. The previously reported deferred view case is tracked separately by #131770 and does not require another inline thread.

Consumers of the rewritten arguments traced:

  • TableFunctionNode hashing, cloning, and toASTImpl retain the qualified arguments.
  • traverseQueryTree and InDepthQueryTreeVisitorWithContext honor the adjusted unresolved-argument indexes.
  • Nested StorageLoop execution receives the qualified inner call before reparsing it.
  • StorageDistributed::buildQueryTreeDistributed preserves remote-target resolution; DistributedCreateLocalPlan avoids rebinding queries printed from resolved trees.
  • TimeSeries parallel-replica reads retain the parent-table identity while sending explicit database and table arguments.
Missing context / blind spots
  • ⚠️ No local ClickHouse executable or build was available, so SQL regressions were inspected but not rerun independently. The author reports failing-on-master/passing-on-head runs, including randomized settings, serialized plans, and parallel replicas. Completed stateless CI results for this head would provide independent runtime confirmation; the fetched report currently has no results for those jobs.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default can be tested Allows running workflows for external contributors comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). labels Nov 14, 2026
Comment thread src/Analyzer/Resolve/QueryAnalyzer.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 427c31267 with master 68d5b2e0a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

120 translation units recompiled, 1184 s compile time in total, 120 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - a3f0fe2

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, s3 storage, DBReplicated, sequential) / 05339_filelog_shared_watch_thread flaky, not from this PR: threads grew by less than the number of tables: 0 instead of 1, both reruns passed; the same test failed on 23 other PRs and 4 times on master in the last 30 days #131241 (mine, open)
Finish Workflow / Post Hooks review-threads gate: 1 unresolved review thread at the end of the run (REVIEW_THREADS_GATE: blocked); no test failure PR-caused by design and owned by this PR (#131589): the resolution is addressing the blocking review thread(s)
Review Threads the same gate as the row above PR-caused by design and owned by this PR (#131589): the resolution is addressing the blocking review thread(s)

Session id: cron:our-pr-ci-monitor:20261114-150101

@PedroTadim

Copy link
Copy Markdown
Member

🕵️ @groeneai The binders look right: loop(t) → loop('<db>', 't') and the dictionary qualification resolve the same objects as before, they are idempotent on re-analysis, and secondary queries are left as sent.

The concern is the approach: this is the second per-function fix (after #122985, with #131528 next), and the same class remains in several table functions. Every function whose database argument goes through evaluateConstantExpressionForDatabaseName treats '' as the current database, so in a subquery or JOIN of a distributed query it reads the default database of the remote server:

  • mergeTreeIndex, mergeTreeAnalyzeIndexes, mergeTreeCodecBlockCounts, mergeTreeTextIndex, projection;
  • timeSeriesData / timeSeriesTags / timeSeriesMetrics / timeSeriesMetricFamilies with a table name without a database (resolveStorageID).

Instead of a typeid_cast per storage in resolveTableFunction, can this be fixed once where the class starts? Each table function's parseArguments already computes the database it reads, so an ITableFunction method that returns its arguments with the database bound would let the analyzer bind them all in this one place (merge, loop and dictionary included), and new table functions would get it for free. The test could then cover one function per kind of argument: identifier, '', and a dictionary name.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Agreed, I'll rework this PR that way. #131528 merged this morning, so its merge binder and the one from #122985 move to the new method as well:

  • an ITableFunction method, called after parseArguments, returns the leading arguments with the database the call resolved: loop(t) -> 'db', 't', mergeTreeIndex('', t) -> 'db', 't', dictionary('d') -> 'db.d', merge(re) -> 'db', re. It is implemented by merge, loop, dictionary, the mergeTree* functions you listed and timeSeries*.
  • resolveTableFunction substitutes them in one place, with the exclusions it has now: a secondary query, the table of remote / cluster, and a query printed from a resolved tree.
  • the test covers one function per kind of argument (identifier, '', dictionary name) through IN and JOIN subqueries of remote.

@ nickitat's draft #128194 adds ITableFunction::getTableArgument for timeSeries* on the parallel replicas path; I'll make the new method cover that case too, so there is one mechanism, not two.

groeneai and others added 4 commits November 16, 2026 11:14
…-remote

Needed by the next commit, which replaces the merge binder that ClickHouse#131528 changed.
A table function that reads the current database, through a name without
a database (`loop(t)`, `dictionary('d')`, `timeSeriesSamples(ts)`) or
through '' (`mergeTreeIndex('', t)`), kept that argument as written in the
query tree. That tree is what remote(), Distributed, *Cluster and
parallel replicas send to other servers, and each of them resolved the
name in its own default database: an IN or JOIN subquery of a
distributed query read other rows or failed with UNKNOWN_TABLE.

As asked in
ClickHouse#131589 (comment),
the knowledge of which arguments name the database moves to the table
function, which computes it in parseArguments: the new virtual
ITableFunction::getQualifiedArguments returns the leading arguments with
that database written out, and QueryAnalyzer::resolveTableFunction
substitutes them in one place. This replaces the `merge` binder of ClickHouse#122985
and ClickHouse#131528 and the `loop` / `dictionary` binder of the first version of
this PR; StorageMerge::getSourceDatabaseNameOrRegexp, which only the
`merge` binder used, is removed. Calls already written that way keep
their nodes. The exclusions are unchanged: the table of remote() or
cluster(), a query printed from a resolved tree (serialize_query_plan
shard plans) and a secondary query.

Implemented by merge, loop, dictionary (a database name containing a dot
stays unqualified), mergeTreeIndex, mergeTreeAnalyzeIndexes,
mergeTreeCodecBlockCounts, mergeTreeTextIndex, mergeTreeProjection,
timeSeriesSamples / Tags / TimeRanges / MetricFamilies (and their
aliases), timeSeriesSelector, prometheusQuery and prometheusQueryRange.
The TimeSeries functions use the `num_table_arguments` names of ClickHouse#128194.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With parallel replicas the TimeSeries functions are sent written out as well (the first problem of ClickHouse#118130).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the QualifiedArguments struct comment (it repeated the method doc) and the skip-index shift comment, shorten the getQualifiedArguments doc and the two num_table_arguments field comments to the invariant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai changed the title Fix loop and dictionary table functions reading the default database of other servers in distributed queries Fix table functions reading the default database of other servers in distributed queries Nov 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review of the rework: adjudication log (click to expand)

Review of the ITableFunction::getQualifiedArguments rework by an independent model (engine: codex) plus my own cold review.

# Sev Finding Verdict Evidence / action
1 ⚠️ no test line shows that parallel replicas now receive the arguments written out AGREE, fixed one timeSeriesTags(ts) read through forced parallel replicas; master fails it with UNKNOWN_TABLE from a replica
2 ⚠️ that line could pass if the initiator declined to fan out DISAGREE under the line's own settings master failed it from a replica in every run, so it fanned out; the settings are pinned in the query; 05175 asserts the fan-out for the same functions and settings (0 failures on master in 30 days)
3 ⚠️ positive lines should also run with serialize_query_plan = 1 DISAGREE the distributed plan CI jobs run every line of the file with serialize_query_plan = 1 (tests/config/users.d/distributed_plan.xml)
4 ⚠️ drop the no-parallel-replicas tags of 05057 / 05140 DISAGREE not this PR's tests
5 💡 the description said already qualified calls keep their arguments, but loop(db.t) becomes loop('db', 't') AGREE, fixed description reworded; same table, only EXPLAIN QUERY TREE shows it

Severity: ❌ blocker / ⚠️ major / 💡 nit.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar @yakov-olkhovskiy, could you review this? It replaces the per-function merge, loop and dictionary binders in resolveTableFunction with one ITableFunction::getQualifiedArguments method, so table functions that read the current database (loop, dictionary, the mergeTree* functions, the timeSeries* functions, prometheusQuery) send it written out to remote servers and parallel replicas instead of reading their default database.

@PedroTadim PedroTadim removed their assignment Nov 16, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. From a database db with db.t = 2, 3 and same-named objects in default holding 0: SELECT sum(number), count() FROM remote('127.0.0.2', numbers(4)) WHERE number IN (SELECT x FROM <tf>) returns 0 1 on master and 26.10.2.103 every run for loop(t), loop('', t), mergeTreeProjection('', t, p), dictionary('d'), loop(dictionary('d')) (and merge('', re) before #131528); the same subquery read locally gives 5 2. The new test fails on master every run with UNKNOWN_TABLE from 127.0.0.2.
b Root cause explained? A table function that reads the current database (a name without a database, or '') binds it only inside the table function object, and the analyzer keeps the argument as written. That query tree is what remote, Distributed, *Cluster and parallel replicas send, so each receiver parses the call again in its own default database. Only merge had a binder (#122985, #131528).
c Fix matches root cause? Yes. Each table function returns, from what its parseArguments computed, its leading arguments with the database written out (ITableFunction::getQualifiedArguments), and the analyzer writes them into the query tree in one place, where it is built. The three per-storage binders are removed.
d Test intent preserved / new tests added? 05634_table_functions_implicit_database_remote: one function per kind of argument (identifier loop(t), '' mergeTreeProjection('', t, p), a dictionary name) through IN and JOIN subqueries of remote, a nested call, fileCluster, one line for each other function with an implementation, a read of timeSeriesTags(ts) through parallel replicas, and the 7 lines that keep the table of remote resolved by the remote server (default and serialize_query_plan = 1). 05634_table_functions_implicit_database_with_dot: a database with a dot in its name. Existing tests unchanged.
e Both directions demonstrated? Yes. Master fails both tests (every positive line: UNKNOWN_TABLE, Dictionary (...) not found, or no row) and the fix passes them. A build without !remote_target fails the remote('127.0.0.2', loop(t)) line and the AS remote(...) table reads, a build without !positional_arguments_already_resolved fails exactly the two serialize_query_plan = 1 reads, and a build without the new block fails all 15 positive lines. 50/50 randomized, also with serialize_query_plan = 1 and parallel replicas.
f Fix is general across code paths? One mechanism for every table function that reads the current database: merge, loop, dictionary, mergeTreeIndex, mergeTreeAnalyzeIndexes, mergeTreeCodecBlockCounts, mergeTreeTextIndex, mergeTreeProjection, the timeSeries* targets, timeSeriesSelector, prometheusQuery(Range); a new one needs only the method. view / viewIfPermitted (query not analyzed on the initiator) are #131770.
g Fix generalizes across inputs (params/datatypes/wrappers)? Identifier, '', quoted name, db.t, dictionary name and nested calls are written out; calls whose arguments already hold these values keep them; a REGEXP database, the UUID form of mergeTreeAnalyzeIndexesUUID and dictionary from a database whose name contains a dot are left as written. Skip-analysis argument indexes move with their arguments. Type wrappers do not apply (names, not values).
h Backward compatible? (maintainer-approved exception only) Yes. No setting. The written-out forms are accepted by 26.10.2.103: a new initiator gets correct rows from a 26.10.2.103 shard, and an old initiator keeps its old result. Secondary queries are not rebound.
i Invariants and contracts preserved? The substitution runs after executeTableFunction, so local reads and errors are unchanged, and the arguments name the same objects the initiator resolved. IN set names are hashed after it, and secondary queries are left as sent, so initiator and shards agree. The exclusions (table of remote / cluster, a query printed from a resolved tree, secondary queries) are the previous version's.

Session id: cron:clickhouse-impl-slot-5:20261116-111200

@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in 6c528f4 : ITableFunction::getQualifiedArguments returns the leading arguments with the database the call resolved written out, and resolveTableFunction substitutes them in one place, which replaces the merge, loop and dictionary binders (exclusions unchanged).

Implemented by merge, loop, dictionary, mergeTreeIndex, mergeTreeAnalyzeIndexes, mergeTreeCodecBlockCounts, mergeTreeTextIndex, mergeTreeProjection, timeSeriesSamples / Tags / TimeRanges / MetricFamilies (and the Data / Metrics aliases), timeSeriesSelector and prometheusQuery(Range). Measured on master from an IN subquery of remote: all of them except merge (already bound there) read the default database of the remote server (the TimeSeries targets through timeSeriesSamples, prometheusQueryRange through prometheusQuery). The TimeSeries ones use the num_table_arguments lines of #128194, so it can call this method. With parallel replicas, timeSeriesTags(ts) now reaches the replicas written out as well, the first problem of #118130 (on master a replica fails with UNKNOWN_TABLE).

The test now covers one function per kind of argument (loop(t), mergeTreeProjection('', t, p), dictionary('d')) through IN and JOIN, plus one line for each other function and one read through parallel replicas.

@clickhouse-gh clickhouse-gh Bot 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.

AI review approves this commit, see the AI Review comment.

@clickhouse-gh clickhouse-gh Bot added comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). and removed comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). labels Nov 16, 2026

This branch has not been deployed

No deployments
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 comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants