Skip to content

read_parquet crashes with NULL dereference when combining encryption_config and union_by_name=true #395

@rajeshpachar

Description

@rajeshpachar

What happens?

read_parquet() crashes with INTERNAL Error: Attempted to dereference shared_ptr that is NULL! when encryption_config is used together with union_by_name=true. Each option works correctly on its own — the crash only occurs when both are combined.

This is a regression from v1.4.3, where the same query works without issue.

Full Error Output

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

Stack Trace:
0        duckdb_adbc_init + 3548796
1        duckdb_adbc_init + 3444796
2        PyInit__duckdb + 207604
3        PyInit__duckdb + 7607676
4        PyInit__duckdb + 7125652
5        PyInit__duckdb + 7135024
6        PyInit__duckdb + 7617300
7        PyInit__duckdb + 7496932
8        duckdb_adbc_init + 6214352
9        duckdb_adbc_init + 8008588
10       duckdb_adbc_init + 7994820
11       duckdb_adbc_init + 7994044
12       duckdb_adbc_init + 7967416
13       duckdb_adbc_init + 7988508
14       duckdb_adbc_init + 7429032
15       duckdb_adbc_init + 7580476

Equivalent pure SQL reproduction:

PRAGMA add_parquet_key('key256', '01234567891123450123456789112345');
COPY (SELECT 1 AS id, 'Alice' AS name) TO '/tmp/enc_test.parquet'
    (FORMAT PARQUET, ENCRYPTION_CONFIG {footer_key: 'key256'});

-- Works:
SELECT * FROM read_parquet('/tmp/enc_test.parquet', encryption_config={footer_key: 'key256'});

-- Crashes:
SELECT * FROM read_parquet('/tmp/enc_test.parquet', encryption_config={footer_key: 'key256'}, union_by_name=true);

Additional Notes

  • The crash also occurs with glob patterns (e.g., 'dir/**/*.parquet') — same behavior.
  • Other options like hive_partitioning, filename, binary_as_string, file_row_number work fine with encryption_config individually.
  • Any combination that includes union_by_name=true with encryption_config triggers the crash.
  • After the crash, the connection is invalidated (FatalException: database has been invalidated because of a previous fatal error).

To Reproduce

import duckdb
import tempfile, os

print(f"DuckDB version: {duckdb.__version__}")

tmpdir = tempfile.mkdtemp()
file_path = os.path.join(tmpdir, "test.parquet")

# Setup: write an encrypted parquet file
conn = duckdb.connect()
conn.execute("PRAGMA add_parquet_key('key256', '01234567891123450123456789112345')")
conn.execute(f"""
    COPY (SELECT 1 AS id, 'Alice' AS name)
    TO '{file_path}'
    (FORMAT PARQUET, ENCRYPTION_CONFIG {{footer_key: 'key256'}})
""")

# Test 1: encryption_config alone — WORKS
r = conn.execute(f"""
    SELECT * FROM read_parquet('{file_path}', encryption_config={{footer_key: 'key256'}})
""").fetchall()
print(f"encryption_config only: {r}")  # [(1, 'Alice')]

# Test 2: union_by_name alone (unencrypted) — WORKS
plain_path = os.path.join(tmpdir, "plain.parquet")
conn.execute(f"COPY (SELECT 1 AS id, 'Bob' AS name) TO '{plain_path}' (FORMAT PARQUET)")
r = conn.execute(f"""
    SELECT * FROM read_parquet('{plain_path}', union_by_name=true)
""").fetchall()
print(f"union_by_name only: {r}")  # [(1, 'Bob')]

# Test 3: both combined — CRASHES on v1.5.0, works on v1.4.3
r = conn.execute(f"""
    SELECT * FROM read_parquet('{file_path}',
        encryption_config={{footer_key: 'key256'}},
        union_by_name=true)
""").fetchall()
print(f"both combined: {r}")  # CRASH

conn.close()
import shutil; shutil.rmtree(tmpdir)

OS:

macOS 15.5 (Darwin 25.0.0), Apple Silicon (arm64)

DuckDB Package Version:

1.5

Python Version:

Python 3.13.11

Full Name:

Rajesh pachar

Affiliation:

THB

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

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

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions