Skip to content

Question: Do we need a result CREATE FUNCTION query #20

@ceckoslab

Description

@ceckoslab

Hello @auxten

I have been adding a few UDFs to my application/playground.

I found that CREATE FUNCTION returns an empty response even when I instruct CHDB that I would like to get the result in JSON.

Example script:

const { query, Session } = require("chdb");

var ret;

// Test standalone query
ret = query("SELECT version(), 'Hello chDB', chdb()", "CSV");
console.log("Standalone Query Result:", ret);

// Test session query
// Create a new session instance
const session = new Session("./udf_create_response");

try {
    const resJson = session.query(`CREATE FUNCTION IF NOT EXISTS to_varchar_json_resp AS (x) -> toString(x);`, "JSON");
    console.log("JSON resp:", resJson);
} catch (e) {
    console.log(e)
}

try {
    const resCsv = session.query(`CREATE FUNCTION IF NOT EXISTS to_varchar_json_resp AS (x) -> toString(x);`);
    console.log("CSV resp:", resCsv);
} catch (e) {
    console.log(e)
}

session.cleanup();

Console output:

Standalone Query Result: "24.5.1.1","Hello chDB","2.0.2"

JSON resp: 
CSV resp: 

I see similar behavior when I use the play function of ClickHouse where the browser receives an empty response when things are Ok.

Screenshot 2024-09-03 at 12 19 56 PM

Not sure if this is a bug or if it can be classified and a serious problem.

I suppose the confusing part was when I expected JSON output but got an empty string. In my code I am treading the results like: JSON.parse(session.query(sql, "JSON")); and I just got a JSON parse error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions