Skip to content

isin triggers assertionfailure #16265

@MarcoGorelli

Description

@MarcoGorelli

What happens?

I'm trying to using the Expressions API to do the equivalent of

select a in [] from rel

To Reproduce

rel = duckdb.sql('select * from values (1,2,1), (3,2,2), (5,3,3) df(a, b, i)')
rel.select(duckdb.ColumnExpression('a').isin())

gives:

InvalidInputException: Invalid Input Error: Attempting to execute an unsuccessful or closed pending query result
Error: INTERNAL Error: Attempted to access index 0 within vector of size 0

Stack Trace:

/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb9Exception6ToJSONENS_13ExceptionTypeERKSs+0x53) [0x7ff6d62a66f3]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb9ExceptionC1ENS_13ExceptionTypeERKSs+0x16) [0x7ff6d62a6726]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb17InternalExceptionC1ERKSs+0x11) [0x7ff6d62a8d31]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb17InternalExceptionC2IJmmEEERKSsDpT_+0x137) [0x7ff6d568eb27]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb6vectorINS_10unique_ptrINS_10ExpressionESt14default_deleteIS2_ELb1EEELb1EE19AssertIndexInBoundsEmm+0x4e) [0x7ff6d56ad38e]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb21ConjunctionExpression8ToStringINS_26BoundConjunctionExpressionENS_10ExpressionEEESsRKT_+0x2f) [0x7ff6d6df4f4f]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZNK6duckdb26BoundConjunctionExpression8ToStringEv+0xa) [0x7ff6d6debf0a]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZNK6duckdb14BaseExpression7GetNameEv+0x16) [0x7ff6d6cb8ec6]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb24RelationStatisticsHelper22ExtractProjectionStatsERNS_17LogicalProjectionERNS_13RelationStatsE+0xf5) [0x7ff6d6c6dfb5]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb15RelationManager20ExtractJoinRelationsERNS_18JoinOrderOptimizerERNS_15LogicalOperatorERNS_6vectorISt17reference_wrapperIS3_ELb1EEENS_12optional_ptrIS3_Lb1EEE+0x13b8) [0x7ff6d6c7bbc8]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb17QueryGraphManager5BuildERNS_18JoinOrderOptimizerERNS_15LogicalOperatorE+0x24) [0x7ff6d6c7c7d4]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb18JoinOrderOptimizer8OptimizeENS_10unique_ptrINS_15LogicalOperatorESt14default_deleteIS2_ELb1EEENS_12optional_ptrINS_13RelationStatsELb1EEE+0x30) [0x7ff6d6c79df0]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(+0x20e36c6) [0x7ff6d6c346c6]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb9Optimizer12RunOptimizerENS_13OptimizerTypeERKSt8functionIFvvEE+0x5b) [0x7ff6d6c3657b]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb9Optimizer20RunBuiltInOptimizersEv+0x338) [0x7ff6d6c368e8]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb9Optimizer8OptimizeENS_10unique_ptrINS_15LogicalOperatorESt14default_deleteIS2_ELb1EEE+0x54) [0x7ff6d6c36fa4]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext31CreatePreparedStatementInternalERNS_17ClientContextLockERKSsNS_10unique_ptrINS_12SQLStatementESt14default_deleteIS6_ELb1EEENS_12optional_ptrISt13unordered_mapISsNS_18BoundParameterDataENS_33CaseInsensitiveStringHashFunctionENS_29CaseInsensitiveStringEqualityESaISt4pairIS3_SC_EEELb1EEE+0x6d4) [0x7ff6d6b3fce4]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext23CreatePreparedStatementERNS_17ClientContextLockERKSsNS_10unique_ptrINS_12SQLStatementESt14default_deleteIS6_ELb1EEENS_12optional_ptrISt13unordered_mapISsNS_18BoundParameterDataENS_33CaseInsensitiveStringHashFunctionENS_29CaseInsensitiveStringEqualityESaISt4pairIS3_SC_EEELb1EEENS_21PreparedStatementModeE+0x2dd) [0x7ff6d6b403cd]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext24PendingStatementInternalERNS_17ClientContextLockERKSsNS_10unique_ptrINS_12SQLStatementESt14default_deleteIS6_ELb1EEERKNS_22PendingQueryParametersE+0x96) [0x7ff6d6b4c786]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext35PendingStatementOrPreparedStatementERNS_17ClientContextLockERKSsNS_10unique_ptrINS_12SQLStatementESt14default_deleteIS6_ELb1EEERNS_10shared_ptrINS_21PreparedStatementDataELb1EEERKNS_22PendingQueryParametersE+0xd7) [0x7ff6d6b53777]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext43PendingStatementOrPreparedStatementInternalERNS_17ClientContextLockERKSsNS_10unique_ptrINS_12SQLStatementESt14default_deleteIS6_ELb1EEERNS_10shared_ptrINS_21PreparedStatementDataELb1EEERKNS_22PendingQueryParametersE+0x10b) [0x7ff6d6b5484b]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext20PendingQueryInternalERNS_17ClientContextLockENS_10unique_ptrINS_12SQLStatementESt14default_deleteIS4_ELb1EEERKNS_22PendingQueryParametersEb+0x96) [0x7ff6d6b539c6]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext20PendingQueryInternalERNS_17ClientContextLockERKNS_10shared_ptrINS_8RelationELb1EEEb+0x153) [0x7ff6d6b58f43]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb13ClientContext12PendingQueryERKNS_10shared_ptrINS_8RelationELb1EEEb+0x44) [0x7ff6d6b59154]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(+0x25340e6) [0x7ff6d70850e6]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb16DuckDBPyRelation15ExecuteInternalEb+0x15) [0x7ff6d70851c5]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb16DuckDBPyRelation16ToStringInternalERKNS_17BoxRendererConfigEb+0x20a) [0x7ff6d708816a]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(_ZN6duckdb16DuckDBPyRelation8ToStringEv+0x181) [0x7ff6d7088471]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(+0x2556e24) [0x7ff6d70a7e24]
/home/marcogorelli/polars-api-compat-dev/.venv/lib/python3.12/site-packages/duckdb/duckdb.cpython-312-x86_64-linux-gnu.so(+0x247cf13) [0x7ff6d6fcdf13]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x399452) [0x7ff6e0af1452]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyObject_MakeTpCall+0x17b) [0x7ff6e0ac422b]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x36f351) [0x7ff6e0ac7351]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x25946f) [0x7ff6e09b146f]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x4c138d) [0x7ff6e0c1938d]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyObject_Repr+0xb4) [0x7ff6e0af1fc4]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x3254e) [0x7ff6e0b66fce]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyObject_Call_Prepend+0x99) [0x7ff6e0ac5e69]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x4c1635) [0x7ff6e0c19635]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x2f87a) [0x7ff6e0b642fa]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyObject_Call_Prepend+0x99) [0x7ff6e0ac5e69]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x4c1635) [0x7ff6e0c19635]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyObject_CallOneArg+0x140) [0x7ff6e0ac50f0]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x7ce5) [0x7ff6e0b3c765]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyEval_EvalCode+0xf8) [0x7ff6e0c5a568]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x4ffe43) [0x7ff6e0c57e43]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x328d6) [0x7ff6e0b67356]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x490d3e) [0x7ff6e0be8d3e]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x490bb7) [0x7ff6e0be8bb7]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x33104) [0x7ff6e0b67b84]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x36f07d) [0x7ff6e0ac707d]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyEval_EvalFrameDefault+0x340e8) [0x7ff6e0b68b68]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(PyEval_EvalCode+0xf8) [0x7ff6e0c5a568]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x5483aa) [0x7ff6e0ca03aa]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x2983af) [0x7ff6e09f03af]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyRun_SimpleFileObject+0x108) [0x7ff6e09ef918]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(_PyRun_AnyFileObject+0x3a) [0x7ff6e09ef58a]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x2a2a3e) [0x7ff6e09faa3e]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x2a27f4) [0x7ff6e09fa7f4]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(Py_RunMain+0x4b9) [0x7ff6e0cb7cd9]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(+0x5602ef) [0x7ff6e0cb82ef]
/home/marcogorelli/.local/share/uv/python/cpython-3.12.6-linux-x86_64-gnu/bin/../lib/libpython3.12.so.1.0(Py_BytesMain+0x2c) [0x7ff6e0cb83ac]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7ff6e044dd90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7ff6e044de40]
/home/marcogorelli/polars-api-compat-dev/.venv/bin/python3(_start+0x29) [0x6000a9]

This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors

OS:

linux

DuckDB Version:

1.2

DuckDB Client:

python

Hardware:

No response

Full Name:

Marco Edward Gorelli

Affiliation:

Quansight Labs

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

I have not tested with any build

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 (e.g., CPU architecture, Python version, Linux distribution) 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