Open subkanthi opened 2 years ago
user_defined_executable_functions_config
is /etc/clickhouse-server/*_functoin.xml
. However clickhouse operator tries to merge any XMLs at the path into server config.xml. I think chop can use some improvement./configs
. Set the search path /configs/*_function.xml
to user_defined_executable_functions_config
to avoid the problem./user_scripts
, set the path to user_scripts_path
So here is a working toy example of deployment yaml. My UDF "cat" calls /bin/cat
command that echos the input. For production, use initContainers
and checkout git and mount, instead of confgMaps in the yaml.
apiVersion: v1
kind: ConfigMap
metadata:
name: udf-configmap
data:
udf_function.xml: |
<functions>
<function>
<type>executable</type>
<name>cat</name>
<return_type>String</return_type>
<argument>
<type>String</type>
</argument>
<format>CSV</format>
<command>cat</command>
</function>
</functions>
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cat-configmap
data:
cat: |
#!/bin/bash
cat
---
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "demo-01"
spec:
configuration:
settings:
user_scripts_path: /user_scripts
user_defined_executable_functions_config: /configs/*_function.xml
clusters:
- name: "demo-01"
templates:
podTemplate: clickhouse:22.3.6.5
layout:
shardsCount: 1
replicasCount: 1
templates:
podTemplates:
- name: clickhouse:22.3.6.5
spec:
containers:
- name: clickhouse-pod
image: clickhouse/clickhouse-server:22.3.6.5
volumeMounts:
- name: clickhouse-user-scripts-volume
mountPath: /user_scripts
- name: clickhouse-configs-volume
mountPath: /configs
volumes:
- name: clickhouse-user-scripts-volume
configMap:
name: cat-configmap
defaultMode: 0755
- name: clickhouse-configs-volume
configMap:
name: udf-configmap
chi-demo-01-demo-01-0-0-0.chi-demo-01-demo-01-0-0.test.svc.cluster.local :) select cat('hi')
SELECT cat('hi')
Query id: 7d8b9cc3-e42e-4d21-a050-1934b4882499
┌─cat('hi')─┐
│ hi │
└───────────┘
This example works so can we close this one?
https://github.com/Altinity/clickhouse-operator/blob/master/docs/chi-examples/23-udf-example.yaml
I just tried both examples and they do not work with the latest clickhouse version 24.8
@pmig could you explain what exactly doesn't work? maybe fix from https://github.com/Altinity/clickhouse-operator/pull/1502 could help you?
Tried to mount two files to support custom UDF's in clickhouse-operator https://chowdera.com/2022/03/202203311616432455.html, see below the yaml file.
Couple of issues, 1) The UDF code(Python file) looks like has to be mounted in
/var/lib/clickhouse/user_scripts
, can't find an example to do that. 2) For some reason theuser_defined_executable_functions_config
is not merged into config.xml. 3) This is the stack trace of the error