Repository navigation
Declarative function signatures - #3775
alexey-milovidov wants to merge 47 commits into
Conversation
|
@alexey-milovidov , sorry for interrupting, just wondering. Why you prefer string representation of signature instead of having a separate method/visitor pattern/whatever with explicit programmatic specification? |
…to function-signatures
We need declarative specification of function signatures for documentation, introspection, analysis. How this signature can be specified in code?
1st variant is easy to write and use but not statically checked. |
|
I will open another PR when the time will come. |
Port the experimental declarative function signature DSL from ClickHouse#3775 onto current master. A `FunctionSignature` is constructed from a string like: transform(T, const Array(T), const Array(U), U) -> U array(T1, ...) -> Array(leastSupertype(T1, ...)) toFixedString(String, const N UnsignedInteger) -> FixedString(N) reverse(T : StringOrFixedString) -> T OR reverse(T : Array) -> T It supports: - type variables (T, U, ...) captured from arguments and reused; - type matchers (UnsignedInteger, Number, StringOrFixedString, Array(...), Tuple(...), MaybeNullable(...), ...); - type functions (leastSupertype, Array, FixedString, DateTime, difference, typeFromString, Nullable, LowCardinality, tuplesHaveSameSize); - `const` arguments, captured by name so their value can drive the return type; - ellipsis (...) for variadic / repeated argument groups; - optional [...] groups; - alternative signatures joined with OR; - WHERE constraints over the captured variables. The result is a single `check` call that takes `ColumnsWithTypeAndName` and returns either the resolved return type or an explanatory error message. This commit only adds the DSL and unit tests under `src/DataTypes/tests/gtest_FunctionSignature.cpp`. It does not yet migrate any existing `getReturnTypeImpl` implementations. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…res-2026 Declarative function signatures, continuation of ClickHouse#3775
Port the experimental declarative function signature DSL from ClickHouse#3775 onto current master. A `FunctionSignature` is constructed from a string like: transform(T, const Array(T), const Array(U), U) -> U array(T1, ...) -> Array(leastSupertype(T1, ...)) toFixedString(String, const N UnsignedInteger) -> FixedString(N) reverse(T : StringOrFixedString) -> T OR reverse(T : Array) -> T It supports: - type variables (T, U, ...) captured from arguments and reused; - type matchers (UnsignedInteger, Number, StringOrFixedString, Array(...), Tuple(...), MaybeNullable(...), ...); - type functions (leastSupertype, Array, FixedString, DateTime, difference, typeFromString, Nullable, LowCardinality, tuplesHaveSameSize); - `const` arguments, captured by name so their value can drive the return type; - ellipsis (...) for variadic / repeated argument groups; - optional [...] groups; - alternative signatures joined with OR; - WHERE constraints over the captured variables. The result is a single `check` call that takes `ColumnsWithTypeAndName` and returns either the resolved return type or an explanatory error message. This commit only adds the DSL and unit tests under `src/DataTypes/tests/gtest_FunctionSignature.cpp`. It does not yet migrate any existing `getReturnTypeImpl` implementations. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
No description provided.