unable to create function

83 views
Skip to first unread message

Ted Yu

unread,
Jun 20, 2023, 6:39:26 PM6/20/23
to ClickHouse
Hi,

When I run :

CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even');

I get:

Error: got status 400, error text: Code: 62. DB::Exception: Syntax error: failed at position 57 ('FORMAT') (line 2, col 1): FORMAT JSONCompact. Expected one of: token, Dot, UUID, DoubleColon, MOD, DIV, NOT, BETWEEN, LIKE, ILIKE, NOT LIKE, NOT ILIKE, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, IS, AND, OR, QuestionMark, end of query. (SYNTAX_ERROR) (version 22.8.12.45 (official build))

I wonder if the 22.8 release supports custom function.
If it does, what have I missed ?

Thanks

Pavel Kruglov

unread,
Jun 21, 2023, 8:54:55 AM6/21/23
to ClickHouse

Hi!

Query `CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even');` works in 22.8 well: https://fiddle.clickhouse.com/b8a5b1f5-2549-4809-9b9e-31fa954ddc55
According to the error message you provided, the query contains `FORMAT JSONCompact` at the end. Maybe you added this suffix to your query somehow? Or it's error for different query?
среда, 21 июня 2023 г. в 00:39:26 UTC+2, ted...@datavisor.com:

Анатолий Серяков

unread,
Jun 21, 2023, 1:21:07 PM6/21/23
to ClickHouse
CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even'); 

Updated Rows 0

Query CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even')
Finish time Wed Jun 21 20:19:25 MSK 2023

Clickhouse version 22.3.2.1
среда, 21 июня 2023 г. в 15:54:55 UTC+3, avo...@clickhouse.com:

Анатолий Серяков

unread,
Jun 21, 2023, 1:22:16 PM6/21/23
to ClickHouse
select parity_str(2), parity_str(3)parity_str

even odd

среда, 21 июня 2023 г. в 20:21:07 UTC+3, Анатолий Серяков:
Reply all
Reply to author
Forward
0 new messages