Skip to content

partial function application and function pipelining - #80277

Closed
yesipoff wants to merge 12 commits into
ClickHouse:masterfrom
yesipoff:partial-function-application-and-function-composition
Closed

yesipoff wants to merge 12 commits into
ClickHouse:masterfrom
yesipoff:partial-function-application-and-function-composition

Conversation

@yesipoff

@yesipoff yesipoff commented May 15, 2025 •

Copy link
Copy Markdown

Changelog category (leave one):

  • New Feature

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

Implementation of partial function application and function pipelining

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@CLAassistant

CLAassistant commented May 15, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@yesipoff
yesipoff force-pushed the partial-function-application-and-function-composition branch from 6f4842a to b936497 Compare May 15, 2025 22:02
@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 15, 2025
@clickhouse-gh

clickhouse-gh Bot commented May 15, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5584c1c]

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label May 15, 2025
@yesipoff
yesipoff force-pushed the partial-function-application-and-function-composition branch from b936497 to 2fe0eb8 Compare May 16, 2025 10:19
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thank you for this idea and the initial implementation! The branch had gone stale (15 months, now conflicting), so I reimplemented the feature on top of the current analyzer in #116029, which supersedes this PR: both f | g and the _/_N placeholders are now resolved as pure rewrites to ordinary lambdas at analysis time, with no runtime compose function, and without reserving _ globally (the existing _ -> _ IN (1)-style lambdas keep working). Credited in the new PR.

alexey-milovidov added a commit to raimannma/ClickHouse that referenced this pull request Oct 11, 2026
`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 ClickHouse#80277 by @yesipoff.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants