Feature/create simple lambda function#23978
Conversation
|
What is missing:
|
|
@Realist007 please add more tests for functionality.
|
|
| class UserDefinedFunction; | ||
| using UserDefinedFunctionPtr = std::shared_ptr<UserDefinedFunction>; | ||
|
|
||
| class UserDefinedFunction : public IFunction |
There was a problem hiding this comment.
It may be logical to use IFunctionOverloadResolver interface.
This UDF is polymorphic, and can be used with different types. However, we don't need to resolve types for every processing block. OverloadResolver can check types and build ready ExpressionActions. Those actions should be used in IFunctionBase.
There was a problem hiding this comment.
Also, looks like we need to disable all useDefaultImplementation flags.
There was a problem hiding this comment.
We have specific values of arguments inside ExpressionActions. Why it will work if we build ExpressionAction once?
…ing create user-defined functions
|
Internal documentation ticket: DOCSUP-13375 |
|
will you support recursive function? CREATE FUNCTION f3 AS a -> multiIf(a < 2, 1, f3(a) + f3(a + 1))
Query id: 38b7b875-5877-4081-ac79-ad0493cc6923
0 rows in set. Elapsed: 0.001 sec.
Received exception from server (version 21.11.1):
Code: 611. DB::Exception: Received from localhost:9000. DB::Exception: You cannot create recursive function. (CANNOT_CREATE_RECURSIVE_FUNCTION) |
|
@l1t1 Not in near time. User defined SQL functions are substituted (as expression) firstly and only then optionally compiled and evaluated. |
|
Any ideas of how to support this? CREATE FUNCTION UDFTestArrayMap AS (d) -> arrayMap( x -> JSONExtractKeysAndValues(x, 'String'), d )
DB::Exception: Identifier `x` does not exist in arguments. (UNKNOWN_IDENTIFIER) (version 21.10.2.15 (official build)) |
|
攒 |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add feature for creating user-defined functions.
Detailed description / Documentation draft:
You can create your function with command 'create function MyFunc as ({parameters}) -> {function core}'. For example: 'create function sum as (a, b) -> a + b'