duckdb / duckdb/duckdb-python

`select()` ignores `distinct`

Aperta
#154 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
needs triage
Lingua principale
Python
Stelle
187
Fork
112
Merge medio
13h 29m
PR unite (30g)
17

Descrizione

### What happens?

`select("distinct ")` ignores `distinct`.

Expected behavior: a) throw an exception if this is not supported or b) apply the distinct.

E.g. `select(count("*")` throws an exception `_duckdb.BinderException: Binder Error: Aggregates cannot be present in a Project relation!`

### To Reproduce

```python
import duckdb
import pandas as pd

df = pd.DataFrame({"a": [1, 2, 1, 1], "b": [10, 10, 10, 20], "c": [0, 1, 2, 3]})
duckdb.execute("CREATE TABLE foo AS SELECT * FROM df")

sql_query_selectdistinct = duckdb.table("foo").select("DISTINCT a, b").sql_query()

print(sql_query_selectdistinct)

assert "SELECT DISTINCT a, b FROM main.foo" == sql_query_selectdistinct
assert duckdb.table("foo").select("a, b").distinct().sql_query() == sql_query_selectdistinct
```

Output:
```
SELECT a, b FROM main.foo
```

Both **assertions fail**

### OS:

Windows 11 x86_64

### DuckDB Package Version:

1.4.1

### Python Version:

3.13.6

### Full Name:

Clemens Korner

### Affiliation:

AIT Austrian Institute of Technology

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia eseguendo il riproduttore Python dell’issue con la DuckDB table API e verifica come select("DISTINCT a, b") e distinct() costruiscono le loro query SQL. L’issue è completata quando la query include SELECT DISTINCT a, b FROM main.foo, oppure quando l’API solleva un’eccezione chiara se quella forma non è supportata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
pandas, python, sql
Ambito
databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.