Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for executable UDF #237

Closed
arnaudbriche opened this issue Jun 28, 2024 · 1 comment
Closed

Support for executable UDF #237

arnaudbriche opened this issue Jun 28, 2024 · 1 comment
Labels
question Further information is requested

Comments

@arnaudbriche
Copy link

Does chdb support executable UDF functions ?
If so, how do we configure chdb ?

@arnaudbriche arnaudbriche added the question Further information is requested label Jun 28, 2024
@auxten
Copy link
Member

auxten commented Jul 1, 2024

chDB is ClickHouse, so all things would be like executable UDF functions

Here is an example:

root@0a8b55995b6e:/auxten/chdb/tests# python3 udf3.py 
"Value 2"

udf3.py

import chdb


ret = chdb.query(
    "SELECT test_function_python(toUInt64(2));",
    udf_path="/auxten/chdb/tests/.udf",
)
print(ret)

.udf/udf.xml

<functions>
    <function>
        <type>executable</type>
        <name>test_function_python</name>
        <return_type>String</return_type>
        <argument>
            <type>UInt64</type>
            <name>value</name>
        </argument>
        <format>TabSeparated</format>
        <command>test_function.py</command>
    </function>
</functions>

DO NOT forget chmod +x .udf/test_function.py
.udf/test_function.py

#!/usr/bin/python3

import sys

if __name__ == '__main__':
    for line in sys.stdin:
        print("Value " + line, end='')
        sys.stdout.flush()

@auxten auxten closed this as completed Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants