Skip to content

where with a Python filter on a Parquet table throws NullPointerException on free-threaded Python #8962

Open

Description

@chipkent

Title: where with a Python filter on a Parquet table throws NullPointerException on free-threaded Python

Description

On Deephaven 42.6 with a free-threaded Python build (3.14t), a where whose filter calls a Python function fails on a table read from Parquet. The same filter works on an in-memory table, on Parquet with a GIL build (3.13), and in several other forms shown below.

Steps to reproduce

import sys

from deephaven_server import Server

Server(port=10000).start()

from deephaven import empty_table, parquet
from deephaven.filters import Filter


def keep(x: int) -> bool:
    return x % 2 == 0


print("GIL on:", getattr(sys, "_is_gil_enabled", lambda: True)())

mem = empty_table(10).update("X = ii")
parquet.write(mem, "/tmp/t.parquet")
pq = parquet.read("/tmp/t.parquet")

cases = {
    "parquet, plain": lambda: pq.where("keep(X)"),
    "parquet, coalesce first": lambda: pq.coalesce().where("keep(X)"),
    "parquet, serial filter": lambda: pq.where(Filter.from_("keep(X)").with_serial()),
    "parquet, select first": lambda: pq.select().where("keep(X)"),
    "parquet, combined with &&": lambda: pq.where("X >= 0 && keep(X)"),
    "in-memory, plain": lambda: mem.where("keep(X)"),
}

for name, run in cases.items():
    try:
        print(f"{name:27} -> {run().size} rows")
    except Exception as e:
        print(f"{name:27} -> FAILED: {'NullPointerException' if 'NullPointerException' in str(e) else e}")

Output on 3.14t (free-threaded)

GIL on: False
parquet, plain              -> FAILED: NullPointerException
parquet, coalesce first     -> FAILED: NullPointerException
parquet, serial filter      -> 5 rows
parquet, select first       -> 5 rows
parquet, combined with &&   -> 5 rows
in-memory, plain            -> 5 rows

On Python 3.13 (GIL build) every case returns 5 rows. Running 3.14t with PYTHON_GIL=1 still fails the same two cases.

Expected

5 rows in every case.

Stack trace

java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "this.usedInputs" is null
    at io.deephaven.engine.table.impl.select.ConditionFilter.getNumInputsUsed(ConditionFilter.java:103)
    at io.deephaven.engine.table.impl.BasePushdownFilterContextImpl.<init>(BasePushdownFilterContextImpl.java:77)
    at io.deephaven.engine.table.impl.sources.regioned.RegionedPushdownFilterContextImpl.<init>(RegionedPushdownFilterContextImpl.java:28)
    at io.deephaven.engine.table.impl.sources.regioned.RegionedColumnSourceManager.makePushdownFilterContext(RegionedColumnSourceManager.java:1055)
    at io.deephaven.engine.table.impl.sources.regioned.RegionedColumnSourceBase.makePushdownFilterContext(RegionedColumnSourceBase.java:171)
    at io.deephaven.engine.table.impl.AbstractFilterExecution.filterStatelessCollection(AbstractFilterExecution.java:542)

Likely cause

A bare vectorizable Python filter is set up through ConditionFilter.setPythonFilter, which leaves usedInputs null. On a free-threaded build, permitParallelization() returns true for it, so the filter goes down the stateless pushdown path. On a regioned (Parquet) source, BasePushdownFilterContextImpl's constructor calls getNumInputsUsed(), which dereferences the null usedInputs. That fits the cases above: a serial filter skips the stateless path, select() and in-memory tables are not regioned, and X >= 0 && keep(X) compiles as an ordinary condition that sets usedInputs. coalesce() keeps the regioned sources, so it still fails. On a GIL build the Python filter is treated as stateful and never reaches the pushdown path; PYTHON_GIL=1 doesn't help because that choice comes from the build, not the runtime GIL state.

Versions

  • Deephaven 42.6 (deephaven-server pip package)
  • Python 3.14.6, free-threading build (fails); Python 3.13 (works)
  • Linux x86_64, Java 21

Activity

  1. added
    bug
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions