surprising `fetchall` return value on some queries, since 1.5.2

Open
#535 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
databases

Research direction

Start by running the provided Python reproductions with DuckDB 1.5.2 and compare their fetchall results with 1.5.1, focusing on CREATE OR REPLACE, PIVOT, and their combination. Done means the combined statement returns the expected result set while the standalone cases continue to pass.

Written by the indexing model from the issue text.

Description

needs triage
What happens?

duckdb.execute of CREATE OR REPLACE or PIVOT each return a result set with row count, but the same call with both statements together returns an empty result since 1.5.2 of the Python library.

To Reproduce

In 1.5.1 and 1.5.2 this succeeds and the assertions pass:

import duckdb

assert duckdb.execute("create or replace table t1 as select 1").fetchall() == [(1,)]
assert duckdb.execute("""PIVOT (
    SELECT 'X' AS category, 100 AS amount
    UNION ALL
    SELECT 'Y' AS category, 200 AS amount
) ON category USING SUM(amount);""").fetchall() == [(100, 200)]

In 1.5.1 we continue to get a result set with CREATE OR REPLACE and PIVOT so this succeeds:

import duckdb

assert duckdb.execute("""create or replace table t1 as PIVOT (
    SELECT 'X' AS category, 100 AS amount
    UNION ALL
    SELECT 'Y' AS category, 200 AS amount
) ON category USING SUM(amount);""").fetchall() == [(1,)]

In 1.5.2 and above, the query succeeds but the assertion fails:

AssertionError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 assert duckdb.execute("""create or replace table t1 as PIVOT (
      2     SELECT 'X' AS category, 100 AS amount
      3     UNION ALL
      4     SELECT 'Y' AS category, 200 AS amount
      5 ) ON category USING SUM(amount);""").fetchall() == [(1,)]

AssertionError:
OS:

OSX

DuckDB Package Version:

1.5.2

Python Version:

3.12.13

Full Name:

Shahin Saneinejad

Affiliation:

Axiom Bio

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
Dominant language
Python
Stars
186
Forks
113
Avg merge
20h 58m
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-python

All issues in duckdb/duckdb-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.