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

UDF String returned results always \x00... #1720

Open
seeya opened this issue Apr 26, 2024 · 0 comments
Open

UDF String returned results always \x00... #1720

seeya opened this issue Apr 26, 2024 · 0 comments

Comments

@seeya
Copy link

seeya commented Apr 26, 2024

What happens?

The returned results of a UDF is always "\x00\x00..." when the returned type is a String.

To Reproduce

Created a sandbox here:
https://codesandbox.io/p/sandbox/small-feather-n3p688?file=%2Fsrc%2FDuckDb.js

Basically create a UDF that returns the exact value. The results will all turn into \x00...

  await c.createScalarFunction('base64', new Utf8(), (a) => {
    console.log(a) // Mark
    return a
  });
  await c.query(`CREATE TABLE people(id INTEGER, name VARCHAR);`);
  await c.query(`INSERT INTO people VALUES (6, 'Mark');`);
  let r = await c.query(`SELECT id, name, base64(name)::VARCHAR as base64 FROM people;`);

  let array = r.toArray().map((row) => row.toJSON());
  console.log(array) // {id: 6, name: 'Mark', base64: '\x00\x00\x00\x00'}

Browser/Environment:

Chrome 124.0.6367.79

Device:

macOS

DuckDB-Wasm Version:

1.28.0

DuckDB-Wasm Deployment:

browser

Full Name:

seeya

Affiliation:

None

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