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

Error when query contains a UNION value #1502

Closed
jraymakers opened this issue Nov 20, 2023 · 4 comments · Fixed by #1503
Closed

Error when query contains a UNION value #1502

jraymakers opened this issue Nov 20, 2023 · 4 comments · Fixed by #1503

Comments

@jraymakers
Copy link
Contributor

What happens?

When the following query is run in DuckDB WASM:

from (values (union_value(str := 'abc')));

an error like the following is returned:

Cannot destructure property 'length' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.
    at VectorLoader.readData (vectorloader.ts:125:56)
    at VectorLoader.visitUtf8 (vectorloader.ts:70:151)
    at VectorLoader.visit (visitor.ts:26:48)
    at VectorLoader.visit (vectorloader.ts:54:22)
    at visitor.ts:23:44
    at Array.map (<anonymous>)
    at VectorLoader.visitMany (visitor.ts:23:22)
    at VectorLoader.visitSparseUnion (vectorloader.ts:103:150)
    at VectorLoader.visit (visitor.ts:26:48)
    at VectorLoader.visit (vectorloader.ts:54:22)

This happens when the query is passed directly to the DuckDB WASM JS API (i.e. query on AsyncDuckDBConnection).

In shell.duckdb.org, running the query above does not return any results, either an error or the correct output.

In the native CLI, the query above returns:

D from (values (union_value(str := 'abc')));
┌────────────────────┐
│        col0        │
│ union(str varchar) │
├────────────────────┤
│ abc                │
└────────────────────┘

To Reproduce

In the esbuild-browser example, replace the query with from (values (union_value(str := 'abc')));.

Browser/Environment:

Chrome 118

Device:

M2 MacBook

DuckDB-Wasm Version:

1.28.0

DuckDB-Wasm Deployment:

local (esbuild-browser example)

Full Name:

Jeff Raymakers

Affiliation:

MotherDuck

@jraymakers
Copy link
Contributor Author

This does not appear to depend on the type of the value in the UNION. For example, using an integer results in the same error with a slightly different stack trace:

from (values (union_value(num := 123)));

Cannot destructure property 'length' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.
    at VectorLoader.readData (vectorloader.ts:125:56)
    at VectorLoader.visitInt (vectorloader.ts:64:113)
    at VectorLoader.visit (visitor.ts:26:48)
    at VectorLoader.visit (vectorloader.ts:54:22)
    at visitor.ts:23:44
    at Array.map (<anonymous>)
    at VectorLoader.visitMany (visitor.ts:23:22)
    at VectorLoader.visitSparseUnion (vectorloader.ts:103:150)
    at VectorLoader.visit (visitor.ts:26:48)
    at VectorLoader.visit (vectorloader.ts:54:22)

@jraymakers
Copy link
Contributor Author

jraymakers commented Nov 20, 2023

Also note that this currently causes all_types.test.ts to fail:

  Test All Types Async
        OK: types with custom config (13ms)
        OK: partially supported types (11ms)
    FAILED: fully supported types (13ms)
        TypeError: Cannot destructure property 'length' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.
            at VectorLoader.readData (packages/apache-arrow/visitor/visitor/vectorloader.ts:125:56 <- packages/duckdb-wasm/dist/tests-browser.js:14648:23)
            at VectorLoader.visitInt (packages/apache-arrow/visitor/visitor/vectorloader.ts:64:113 <- packages/duckdb-wasm/dist/tests-browser.js:14580:111)
            at VectorLoader.visit (packages/apache-arrow/visitor.ts:26:48 <- packages/duckdb-wasm/dist/tests-browser.js:8859:46)
            at VectorLoader.visit (packages/apache-arrow/visitor/visitor/vectorloader.ts:54:22 <- packages/duckdb-wasm/dist/tests-browser.js:14571:20)

@jraymakers
Copy link
Contributor Author

I'm pretty sure this is caused by this bug in apache-arrow, which was fixed in version 14. So upgrading apache-arrow should fix this.

@jraymakers
Copy link
Contributor Author

I've confirmed that upgrading to apache-arrow v14.0.1 (the latest at the time of this writing) fixes this issue.

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

Successfully merging a pull request may close this issue.

1 participant