#26272·duckdb

Arrow scan of list<dictionary> fails when the first 2048 rows hold no list elements

Author: okaistiCreated Sep 29, 2026Updated Sep 29, 2026

What happens?

Scanning an Arrow list<dictionary<int32, string>> column fails with an internal error when the first scan chunk (the first 2048 rows) contains zero list elements and later rows contain values:

INTERNAL Error: Attempted to dereference unique_ptr that is NULL!

In DuckDB-WASM (1.31.0, DuckDB v1.4.0) the same input produces Failed to cast ArrowTypeInfo, type mismatch (expected: STRING, got: LIST), and the database is then invalidated. That is how we hit it in production: insertArrowFromIPCStream into a VARCHAR[] table.

It passes when the child is plain utf8, and when even one of the first 2048 rows holds a value. It also passes when the only all-empty chunk is not the first one.

The cause appears to be the empty-list shortcut in ArrowToDuckDBList (src/function/table/arrow_conversion.cpp#L228-L233):

cpp
if (list_size == 0 && start_offset == 0) {
    D_ASSERT(!child_array.dictionary);
    ArrowToDuckDBConversion::ColumnArrowToDuckDB(child_vector, child_array, chunk_offset, child_state, list_size,
                                                 child_type, -1);
    return;
}

start_offset == 0 with list_size == 0 only happens when no earlier row had elements, so it is reached only by an empty first chunk. A dictionary-encoded child reaches it despite the debug-only assert, and it is converted as a plain column. For a dictionary child, child_type is the index type, which arrow_duck_schema.cpp#L80-L81 builds as ArrowType(INTEGER) with no type_info. The VARCHAR branch then calls arrow_type.GetTypeInfo<ArrowStringInfo>() (arrow_conversion.cpp#L846) on that null type_info. The WASM build presumably doesn't trap the null read, which would explain its type-mismatch message instead of the null-dereference error.

To Reproduce

python
import duckdb
import pyarrow as pa

# 2049 rows: the first 2048 lists are empty, the last holds one value.
offsets = pa.array([0] * 2049 + [1], pa.int32())
child = pa.array(["a"]).dictionary_encode()  # dictionary<values=string, indices=int32>
tbl = pa.table({"l": pa.ListArray.from_arrays(offsets, child)})

print(duckdb.sql("SELECT * FROM tbl").fetchall()[-1])

Result: _duckdb.InternalException: INTERNAL Error: Attempted to dereference unique_ptr that is NULL!

Expected: (['a'],), which is what you get after removing .dictionary_encode().

OS:

macOS 27.0, arm64

DuckDB Version:

1.5.6 (also 1.4.0, and the same code is on main at 8681dc52)

DuckDB Client:

Python (pyarrow 25.0.1); also DuckDB-WASM 1.31.0

Hardware:

Apple Silicon

Full Name:

Oliver Kaisti

Affiliation:

Sitedrive

Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?

  • Yes, I have

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant data sets for reproducing the issue?

Yes (the script generates its own data)