ClickHouse / ClickHouse/ClickHouse

udf for constants is executed many times

Open
#40,283 1 comment 0 reactions 0 assignees View on GitHub
comp-udf external feature
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

**Use case**
I have my UDF:
>CREATE OR REPLACE FUNCTION string2words AS (str) -> arrayDistinct(arraySort(arrayFilter(x -> x != '', arrayMap(x -> stem('ru', x), arrayMap(x -> stem('en', x), arrayMap(x -> stem('el', x), splitByRegexp('[^a-zA-ZА-Яа-я0-9α-ωΑ-ΩίϊΐόάέύϋΰήώΊΪΌΆΈΎΫΉΏ]+', lowerUTF8(str))))))))

When I use it in WHERE:
>WHERE hasAll(words, string2words('привет'))

It is executed many times and work too slow.

When I use it separately `SELECT string2words('привет');` and after `WHERE hasAll(words, ['привет'])` works faster in 3-4 times

**Describe the solution you'd like**

I woud like UDF is executed only once if all parameters of UDF are constants.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.