Skip to content

Add the function composition operator f | g and argument placeholders - #116029

Merged
alexey-milovidov merged 26 commits into
masterfrom
function-composition-operator
Oct 10, 2026
Merged

alexey-milovidov merged 26 commits into
masterfrom
function-composition-operator

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Related: #80277

Continues and supersedes #80277 by @yesipoff (thanks for the idea and the initial implementation — the branch lives in a fork and is 15 months stale, so this is a reimplementation rather than a rebase).

What it does

f | g is a function that applies f and then g. It can be used wherever a function is expected, that is, as an argument of a higher-order function:

SELECT arrayMap(plus(_, 1) | multiply(_, 2), [1, 2, 3]);      -- [4, 6, 8]
SELECT arrayMap(negate | abs | toString, [1, 2, 3]);          -- ['1', '2', '3']
SELECT arrayFilter(modulo(_, 2) | equals(_, 1), [1, 2, 3, 4, 5]); -- [1, 3, 5]
WITH (x -> x + 1) AS inc SELECT arrayMap(inc | inc, [1, 2, 3]);   -- [3, 4, 5]

Operands can be lambdas, names of functions (builtins, SQL/executable UDFs, and WITH-bound lambdas), nested compositions, and expressions with the argument placeholders _, _1, _2, ... The placeholders also work on their own in the lambda position of a higher-order function, including inside operators and at any depth:

SELECT arrayMap(_1 * 2 + 1, [1, 2, 3]);                       -- [3, 5, 7]
SELECT arrayMap(pow(_2, _1), [3, 2, 1], [9, 10, 11]);         -- [729, 100, 11]
SELECT arrayMap(multiply(_1, _1), [1, 2, 3]);                 -- [1, 4, 9]
SELECT arrayFold(_1 + _2, [1, 2, 3], 0::UInt64);              -- 6

How it works

Both features are pure syntax sugar over lambdas, resolved entirely at query analysis time; there is no runtime compose function and no new execution machinery.

  • The parser maps | to compose(f, g) (one line in the operator table). The single | was previously a syntax error, and || (concatenation) and |> (pipe operators) are separate tokens, so nothing changes for them. SELECT 1 | 2 reports a dedicated error pointing to bitOr.
  • The analyzer fuses a compose node in a function argument position into one ordinary lambda (args...) -> g(f(args...)) by substituting the body of f for the argument of g — the same inlining semantics as SQL user defined functions. The arguments of f are renamed to fresh reserved names first, so a column referenced from the body of g can never be captured accidentally; member access on the substituted value folds into tupleElement chains.
  • A placeholder expression is lifted to a lambda whose argument names are literally _1 ... _n, so numbered placeholders need no substitution at all and work at any depth; the largest number determines the arity, and _ introduces one argument per occurrence in the order of occurrence.
  • After the rewrite, only the standard lambda machinery is involved: typing, captures, constant folding, distributed execution — nothing is special-cased downstream. For comparison, partial function application and function pipelining #80277 implemented compose as a 208-line runtime function on ColumnFunction plus ~300 lines of special cases threaded through QueryAnalyzer.

No previously valid query changes meaning: outside a composition, the placeholder lift applies only when the parent function reports isHigherOrderFunction (the same gate as the existing arrayMap(toUpper, arr) bare-function-name rewrite) and only when the placeholder names do not resolve to anything in scope, so columns and aliases keep priority. Every query the rewrite activates on is an error without it. In particular, _ as a lambda parameter (arrayExists(_ -> _ IN (1), x)) and columns named _1 keep working — #80277 had to rename such lambda parameters in two existing tests, this implementation keeps them intact (both cases are covered by the new tests).

The arity probe shared with the bare-function-name rewrite (builtins, executable/WebAssembly UDFs from the resolver, SQL UDFs from the stored CREATE FUNCTION AST) is factored into tryGetRegisteredFunctionArity and reused for composition operands.

The feature is analyzer-only, like the bare-function-name rewrite. Documentation is added to the operators reference page.

Changelog category (leave one):

  • New Feature

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

Added the function composition operator f | g (a function that applies f and then g) and the argument placeholders _, _1, _2, ...: arrayMap(plus(_, 1) | multiply(_, 2), [1, 2, 3]) returns [4, 6, 8]. A composition can be used wherever a function is expected, i.e. as an argument of a higher-order function; operands can be lambdas, names of functions, nested compositions, or expressions with placeholders, which also work on their own: arrayMap(_1 * 2 + 1, [1, 2, 3]). The composition is resolved at query analysis time into an ordinary lambda. Note that the single | is not bitwise OR — use the bitOr function for that.


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

Version info

  • Merged into: 26.10.1.2080-master (included in 26.10 and later)

alexey-milovidov and others added 5 commits August 23, 2026 23:48
`f | g` parses into `compose(f, g)` and is resolved by pure rewriting into an
ordinary lambda `(args...) -> g(f(args...))` during query analysis, so no runtime
support is needed and the standard lambda machinery (typing, captures, execution)
applies unchanged.

Operands can be lambdas, names of functions, nested compositions, or expressions
with the argument placeholders `_`, `_1`, `_2`, ...: `plus(_, 1)` is lifted to
`_1 -> plus(_1, 1)`. Numbered placeholders work at any depth because they become
the names of the lambda arguments. Outside a composition, placeholders apply in
the lambda position of a higher-order function, gated the same way as the
bare-function-name rewrite: the parent must report `isHigherOrderFunction` and
the names must not resolve in scope, so every query the rewrite activates on is
an error without it and no previously valid query changes meaning.

The arity probe shared with the bare-function-name rewrite is factored into
`tryGetRegisteredFunctionArity`.

Continues and supersedes the approach of #80277 by @yesipoff.

Co-Authored-By: Claude Fable 5 <[email protected]>
Also make the substitution treat a nested composition as a binding scope for
placeholder-shaped names, and report a composition resolved outside of a
function argument position with a dedicated error before its operands are
resolved.

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
The rewrites exist only in the analyzer, mirroring the bare-function-name
rewrite test; the placeholders test creates a global SQL UDF, so it cannot
run in parallel with itself in the flaky check.

Co-Authored-By: Claude Fable 5 <[email protected]>
All outputs are produced by the built server and match the hand-computed
expectations; the lambda arity mismatch in arrayMap reports
ILLEGAL_TYPE_OF_ARGUMENT.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [040361a]

Summary: ✅


AI Review

Summary

This PR adds the f | g composition operator and _ / _N placeholder sugar by lowering both to ordinary lambdas during analysis. Most of the earlier scoping, subquery, and identity issues are fixed and well covered by the new stateless tests, but one correctness hole remains: placeholder-bearing composition operands still ignore bound-name precedence and can silently reinterpret legal queries that bind _1 / _2, so I cannot approve it as-is.

Findings

❌ Blockers

  • [src/Analyzer/Resolve/FunctionCompositionRewrite.cpp:521] [dismissed by author -- https://github.com/Add the function composition operator f | g and argument placeholders #116029#discussion_r4038314056] Placeholder expressions used as composition operands still bypass the "bound names win" rule. In the FUNCTION branch, normalizeOperandToLambda treats any operand with free _N tokens as placeholder syntax and immediately calls liftPlaceholdersToLambda, unlike the standalone higher-order path in resolveFunction.cpp:2367, which first checks whether those names already resolve in scope. As a result, WITH 10 AS _1 SELECT arrayMap(plus(_1, 1) | toString, [7]); is rewritten as if plus(_1, 1) meant x -> x + 1, silently discarding the legal _1 alias instead of rejecting the non-function operand. I still consider this real because the docs and the sibling rewrite path both promise that bound names keep priority over placeholders.
    Suggested fix: mirror the scope-precedence guard before liftPlaceholdersToLambda in this branch, and add a regression for bound _1 / _2 inside a composed placeholder expression.
Final Verdict

Status: ❌ Block

  • Mirror the bound-name-precedence check for placeholder-bearing composition operands and add the focused regression above.

LLVM Coverage Report

Measured on commit 040361a.

Metric Baseline Current Δ
Lines 88.20% 88.30% +0.10%
Functions 92.10% 92.10% +0.00%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 428/471 (90.87%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Aug 24, 2026
@mintlify

mintlify Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Oct 6, 2026, 1:36 PM

@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 040361a67 with master 7d4c81bc6 (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.

Object file sizes

6 object files changed (+176.19 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Analyzer/Resolve/FunctionCompositionRewrite.cpp.o new 153.29 KiB +153.29 KiB
src/CMakeFiles/dbms.dir/Analyzer/Resolve/resolveFunction.cpp.o 1.04 MiB 1.06 MiB +18.96 KiB (+1.78%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

102 translation units recompiled, 563 s compile time in total, 101 of them have a recent master baseline.

Job report

…ft bare placeholders

The `f | g` operator parsed into a function node named `compose`, which took the
public name away from users: an existing `CREATE FUNCTION compose AS (x, y) -> x + y`
could no longer be called, because the rewrite hijacked every `compose(...)` call in
a higher-order argument and the standalone check threw before `FunctionFactory` and
`UserDefinedSQLFunctionFactory` were consulted. The operator now uses the internal
name `__compose` (`function_composition_name`), so `compose` is an ordinary name again.

A bare placeholder is now the identity function. It is lifted in the lambda position
of a higher-order function, so `SELECT arrayMap(_1, [1, 2, 3])` resolves to
`_1 -> _1` instead of failing with `UNKNOWN_IDENTIFIER`, and it is accepted as an
operand of the composition operator, so `arrayMap(_1 | plus(_, 1), [1, 2])` composes
the identity with `plus(_, 1)` instead of failing with `BAD_ARGUMENTS`. An argument
that is already a lambda is left alone: a free placeholder in a lambda body is an
ordinary identifier, and lifting it would produce a lambda returning a lambda.

Substitution into a subquery no longer rejects a subquery that merely reuses the
substituted name locally. `subqueryReferencesIdentifier` first collects the names
bound inside the subquery - aliases, CTE names, and lambda arguments - so
`(x -> x + 1) | (x -> x + (SELECT max(x) FROM (SELECT 1 AS x)))` is composed as an
ordinary lambda. Whether a bare identifier is a column of a table inside the
subquery cannot be decided without the catalog, so such a name is still treated as
referenced and the composition fails cleanly with `NOT_IMPLEMENTED`.

Adds the regressions the review asked for: a user defined function named `compose`,
`arrayMap(_1, [1, 2, 3])`, `arrayMap(_1 | plus(_, 1), [1, 2])`, and a composition
whose lambda body contains a non-capturing scalar subquery with a local `x`.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Addressed the AI review in 1f17a70 (blocker + 3 majors + the requested regressions), and merged master.

  • The f | g operator now parses into the internal name __compose, so the public name compose is no longer stolen and a user defined function named compose keeps working.
  • A bare placeholder is the identity function, both in the lambda position of a higher-order function (arrayMap(_1, [1, 2, 3])) and as an operand of the composition (arrayMap(_1 | plus(_, 1), [1, 2])).
  • Substitution into a subquery is now decided by subqueryReferencesIdentifier, which accounts for names bound inside the subquery (aliases, CTE names, lambda arguments) instead of a raw lexical scan.
  • New test 05045_function_composition_udf_name, plus additions to 05038_function_composition_operator and 05039_placeholders_partial_application.

@groeneai, the only red check on the previous run was Stress test (arm_tsan) -> Hung check failed, possible deadlock found (https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116029&sha=95a63ffef1e8bd74c2f40e459c2de9a9b6f3fce9&name_0=PR&name_1=Stress%20test%20(arm_tsan)). The hung stack is a query stuck in DB::Context::executeTableFunction under EXPLAIN, with nothing related to this change on it, so it looks unrelated. If it reproduces after this run, please investigate and provide a fix in a separate PR; if a fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

The executeTableFunction frames are not the hung query. They are the throw site of an exception that already completed: Code: 60. DB::Exception: Table test_e2d0r7v6o4q1.<non-UTF-8 name> does not exist. (UNKNOWN_TABLE), raised under InterpreterExplainQuery::executeImpl from 04511_cascades_replicated_subplan_join.sql (EXPLAIN PIPELINE header = 0 SELECT count(), sumMap(f.v) FROM rsj_fact AS f INNER JOIN (... remoteSecure(...) AS d2 ...)). Frames 0 to 4 of that stack are DB::Exception constructors, which is what marks it as a throw site rather than a live thread. hung_check.log prints a registry of distinct exception messages after the processlist, and CIDB keeps only the last 32 KiB of the job output, so on this artifact the registry is what survives and the processlist is in the discarded head. That is where both executeTableFunction and EXPLAIN in the report come from.

The single actually hung query, from hung_check.log:

SELECT 'x Nullable(Int32), y Nullable(Int32)',
    sum(length(h3PolygonToCellsWithContainment([
        (37.81331899998324, -122.40898669999721),
        (-122.35447369999936, 37.71980619999785),
        (9007199254740994., 9007199254740992.)], 9, 0)))
FROM numbers(9223372036854775807)

elapsed 3277, is_cancelled 1, one thread, no wait frames:

contrib/h3/src/h3lib/lib/polyfill.c:775                 maxPolygonToCellsSizeExperimental
contrib/h3/src/h3lib/lib/polyfill.c:441                 iterStepPolygonCompact
src/Functions/h3PolygonToCellsWithContainment.cpp:277   executeImpl

So your conclusion holds and this is unrelated to f | g. The out-of-domain vertices defeat the bounding box heuristic inside maxPolygonToCellsSizeExperimental, and that walk runs inside a single library call that observes neither max_execution_time nor KILL QUERY.

The fix already in progress is your own #116225. Its check rejects this polygon at the first vertex, whose latitude is -122.4, before maxPolygonToCellsSizeExperimental is reached, and its regression test is the same mutation: same first two vertices, same resolution 9, same containment flag. @ Algunenano's #116335 carries the same range check plus per-cell cancellation for the enumeration walk.

Neither is on master yet, so the new run can hit this again. If it does, the owner is still #116225, so I am not opening a separate PR for it.

…n-operator

Conflict in `src/Analyzer/Resolve/resolveFunction.cpp`: this branch extracted the
inner-function arity probe of the higher-order rewrite into
`tryGetRegisteredFunctionArity`, while master taught the same probe to take the arity of a
`CREATE FUNCTION ... LANGUAGE WASM` definition from the stored AST when no WebAssembly
engine is registered. Kept the extraction and ported master's `ASTCreateWasmFunctionQuery`
case into the helper.
…ubquery guard scope-sensitive

Two problems in the composition rewrite, both reported by the AI review.

The arguments of the fused lambda were named `__composed_arg_N` unconditionally. The name is
unlikely, but not impossible, to occur in a query, and when it does the renaming introduces
exactly the capture it exists to prevent: in
`SELECT arrayMap((x -> x + 1) | (y -> y + __composed_arg_1), [1]) FROM (SELECT 10 AS
__composed_arg_1)` the reference from the right operand bound to the argument of the fused
lambda, so the result was `[3]` instead of `[12]`. The preferred name is now disambiguated with
a counter until it occurs in neither operand, which is enough: a name absent from both bodies
cannot capture anything in them.

`subqueryReferencesIdentifier` decided whether a subquery references a name from the outside
with one flat set of every name bound anywhere inside it, so a nested binder suppressed the
guard for an unrelated free occurrence of the same name:
`SELECT arrayMap((x -> x + 1) | (x -> x + (SELECT arrayMap(x -> x, [1])[1] + x)), [1])` has a
free outer `x` at the top level of the subquery, but the inner `arrayMap(x -> x, ...)` binder
hid it and the rewrite skipped the intended `NOT_IMPLEMENTED` rejection. The walk is now scope
sensitive: a lambda argument binds only inside the body of its lambda, and an alias or a CTE
name only inside the query that defines it. The names a query level binds now also include the
columns the subqueries in its join tree expose, so a name that is merely reused locally, as in
`(SELECT max(x) FROM (SELECT 1 AS x))`, is still recognized as bound.

New test `05048_function_composition_scoping`.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Addressed the two AI review blockers in 7e713a1 and merged master.

  • The arguments of the fused lambda are now disambiguated until they occur in neither operand, so a column named like __composed_arg_1 and referenced from either operand is still captured from the outside.
  • subqueryReferencesIdentifier is scope sensitive: a lambda argument binds only inside its own body, an alias or a CTE name only inside the query that defines it, and the names bound at a query level include the columns exposed by the subqueries in its join tree. A nested binder no longer hides an unrelated free occurrence of the same name, so the intended NOT_IMPLEMENTED rejection is not skipped.
  • New test 05048_function_composition_scoping covers both, including the exact queries from the review.

The merge of master had one conflict, in src/Analyzer/Resolve/resolveFunction.cpp: this branch extracted the inner-function arity probe into tryGetRegisteredFunctionArity, while master taught the same probe to read the arity of a stored CREATE FUNCTION ... LANGUAGE WASM definition when no WebAssembly engine is registered (#116000 area, commit e9ec5ea7cbe5). Kept the extraction and ported master's ASTCreateWasmFunctionQuery case into the helper, so SELECT arrayMap(wasm_is_prime, [7 :: UInt32]) still fails close.

… tighter subquery guard

Three blockers from the review of the function composition operator `f | g`.

The operator no longer reserves any name. `__compose` is a legal identifier, so a stored
`CREATE FUNCTION __compose AS (x, y) -> x + y` used to become unreachable. What makes a node a
composition is now the operator syntax the parser recorded in `is_operator`, checked by the new
`isFunctionComposition`, not the name alone, so an ordinary call to a function of that name
resolves as usual. `ASTFunction` formats such a node back as `f | g`, so a format and parse
round trip keeps the operator instead of degrading it to a call of an unknown function.

A name bound in the query keeps priority over the placeholder syntax also when it is bound as a
function rather than as an expression. A lambda bound with `WITH (x -> x + 10) AS _1` lives in
`ScopeAliases::alias_name_to_lambda_node`, which the expression lookup does not see, so both the
higher-order lift and `normalizeOperandToLambda` turned `arrayMap(_1, [1, 2])` and
`arrayMap(_1 | toString, [1, 2])` into the identity instead of applying the alias. The lift now
consults `isFunctionAliasInScope` as well, and the composition operand tries the scoped
resolution before the placeholder fast path.

`subqueryReferencesIdentifier` no longer lets a table alias or a CTE name suppress the
`NOT_IMPLEMENTED` guard for a bare identifier. `IdentifierResolver::tryBindIdentifierToTableExpression`
rejects a one-part expression lookup once column lookup misses, so `FROM (SELECT 1 AS z) AS y`
makes `y.z` local but leaves a bare `y` free. The bound names are split accordingly into the
ones that bind an expression identifier (lambda arguments, aliases, and the columns a subquery
in the join tree projects) and the ones that bind only a qualifier.

New test `05054_function_composition_name_and_alias_priority` covers the three cases from the
review.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Addressed the three AI review blockers in a74fcd6 and merged master.

  • The f | g operator reserves no name. A node is a composition because the parser marked it as operator syntax (is_operator), not because of its name, so CREATE FUNCTION __compose AS (x, y) -> x + y keeps working, as does any function named compose. ASTFunction formats such a node back as f | g, so a format and parse round trip preserves the operator; formatQuery is idempotent on the result.
  • A name bound in the query keeps priority over the placeholder syntax also when it is bound as a function: the higher-order lift consults isFunctionAliasInScope, and the composition operand tries the scoped resolution before the placeholder fast path. WITH (x -> x + 10) AS _1 SELECT arrayMap(_1, [1, 2]) and ... arrayMap(_1 | toString, [1, 2]) apply the alias.
  • subqueryReferencesIdentifier splits the bound names into the ones that bind a bare expression identifier and the ones that bind only a qualifier. A table alias or a CTE name no longer suppresses the NOT_IMPLEMENTED guard for a bare identifier, matching IdentifierResolver::tryBindIdentifierToTableExpression, which rejects a one-part expression lookup once column lookup misses.

New test 05054_function_composition_name_and_alias_priority covers all three, and the reference of 05038_function_composition_operator is updated for the operator formatting.

…eries

`collectNamesBoundInJoinTree` recorded every alias under the join tree as a
qualifier-only name, but the alias of an `ARRAY JOIN` expression binds a bare
identifier (`IdentifierResolver::tryBindIdentifierToArrayJoinExpressions`).
So `SELECT arrayMap((x -> x + 1) | (y -> y + (SELECT max(y) FROM numbers(1)
ARRAY JOIN [5] AS y)), [1])` was rejected with `NOT_IMPLEMENTED` although the
inner `y` is local. An unaliased `ARRAY JOIN y` stays conservative, since the
joined `y` is itself looked up in that scope.

Addresses review feedback on #116029

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread src/Analyzer/FunctionNode.h Resolved
alexey-milovidov and others added 3 commits October 2, 2026 22:24
…bquery guard

A column a join-tree subquery exposes was treated as bound in the query that selects
from it, even when the expression behind the column is itself an outer reference to
the substituted name, e.g. `y` in `FROM (SELECT y) AS s`. That suppressed the
`NOT_IMPLEMENTED` guard, and after fusion the surviving `y` resolved against the
enclosing query instead of the lambda input. Check the subqueries of the join tree
with only the bindings of the enclosing scopes before collecting the names of the
query level.

Address review comment by `clickhouse-gh` on `collectProjectionNames`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tree hashes

`is_operator` decides whether a `__compose` node is the function composition
operator or an ordinary call to a function of that name, but
`ASTFunction::updateTreeHashImpl`, `FunctionNode::isEqualImpl`, and
`FunctionNode::updateTreeHashImpl` ignored it, so the two expressions collided:
e.g. `MULTIPLE_EXPRESSIONS_FOR_ALIAS` was not raised for them. Take `is_operator`
into account for this function name only, so that `a + b` and `plus(a, b)` remain
the same expression.

Address review comment by `clickhouse-gh` on `FunctionNode::isOperator`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…subqueries

A subquery cannot reference the argument of an explicit lambda either
(`arrayMap(x -> (SELECT x), [1])` fails), so descending into subqueries
would not make placeholders equivalent to explicit lambda arguments.
Document the exclusion and add a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… nested call

The placeholder scan of the lambda position of a higher-order function descended
into the lambda position of a nested higher-order function call, so in
`arrayMap(arrayMap(_ + 1, _1), [[1, 2], [3]])` the `_` of the inner call and the
`_1` of the outer one were collected together and rejected as mixed placeholders.

Now the scan skips the first argument of a nested call to a higher-order function
(unless it is already a lambda): the nested call lifts its own placeholders when
it is resolved, so the query above means
`arrayMap(x -> arrayMap(y -> y + 1, x), [[1, 2], [3]])`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ames in `f | g` operands

An identifier operand of the function composition operator that resolves to a
column or an alias is now rejected instead of silently composing the registered
function with the same name, mirroring the bare-function-name rewrite for
higher-order functions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
{
resolver = UserDefinedExecutableFunctionFactory::tryGet(function_name, context);
}
catch (const Exception & e)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was suspicious, but it came from already existing code.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
Merged via the queue into master with commit 3034fdd Oct 10, 2026
150 checks passed
@alexey-milovidov
alexey-milovidov deleted the function-composition-operator branch October 10, 2026 23:01
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 10, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@alexey-milovidov — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). 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.

5 participants