Canner / wren-engine

🤖 The semantic engine for LLMs, bringing semantic context to AI agents. 🔥
https://getwren.ai/oss
Apache License 2.0
129 stars 34 forks source link

feat(core): implement file-based remote function register #829

Closed goldmedal closed 1 month ago

goldmedal commented 1 month ago

Description

When planning a SQL, DataFusion planner will strictly check the function usage. The used function should be registered in the SessionContext. In the Wren AI scenario, we always fully push down the SQL to the data source side. We can invoke the ByPassFunction (introduced by #802) which only requires the function name and return type to register a logical function for unparsing purposes.

This PR introduces a file-based register to define the required remote function easily.

Definition File

The definition file is a CSV file that contains 4 columns and with the header:

Sample

function_type,name,return_type,description
scalar,add_two,int,"Adds two numbers together."
aggregate,median,int,"Returns the median value of a numeric column.".
window,max_if,int,"If the condition is true, returns the maximum value in the window."

Set up the config

On the ibis server side, we add a new environment variable called REMOTE_FUNCTION_LIST_PATH which is the path of the definition file. We should set up it before starting the server.

Known Issue