duckdb / duckdb/duckdb-python

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

Abierto
#535 0 comentarios 0 reacciones 0 asignados Ver en GitHub
needs triage
Lenguaje dominante
Python
Estrellas
187
Forks
112
Merge medio
13 h 29 min
PR fusionados (30 d)
17

Descripción

### 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?

- [x] Yes, I have

### Did you include all relevant configuration to reproduce the issue?

- [x] Yes, I have

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza ejecutando las reproducciones de Python proporcionadas con DuckDB 1.5.2 y compara sus resultados de fetchall con los de 1.5.1, centrándote en CREATE OR REPLACE, PIVOT y su combinación. Se considera completado cuando la instrucción combinada devuelve el conjunto de resultados esperado, mientras que los casos independientes siguen pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
databases
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.