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

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

Open
ceckoslab opened this issue Sep 3, 2024 · 0 comments
Open

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

ceckoslab opened this issue Sep 3, 2024 · 0 comments

Comments

@ceckoslab
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant