clickhouse-sqlalchemy icon indicating copy to clipboard operation
clickhouse-sqlalchemy copied to clipboard

Can't Create a clickhouse udf function By using execute method

Open superjcd opened this issue 2 years ago • 2 comments

Describe the bug I want create a udf function like below:

CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b;  

But it failed; Exception came from the database says : Syntax error (Multi-statements are not allowed): failed at position 72 (end of query): ; FORMAT TabSeparatedWithNamesAndTypes. . (SYNTAX_ERROR) (version 22.2.2.1)

So I checked the source code, It seems that a subfix will be always added to the raw syntex; It turn out that my input eventually will be like:

CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; FORMAT TabSeparatedWithNamesAndTypes

To Reproduce

sql = "CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; "

with engine.connect() as connection:
    connection.execute(sql)

superjcd avatar Aug 09 '22 06:08 superjcd

Try use clickhouse+native:// schema. HTTP dialect has poor support in this package.

xzkostyan avatar Aug 09 '22 13:08 xzkostyan

It works, thanks

superjcd avatar Aug 10 '22 02:08 superjcd