Skip to content

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

Open
@seeya

Description

@seeya

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

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