apache / apache/datafusion

support more date inferences in the csv reader

Aperta
#9,331 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Rust
Stelle
9.3k
Fork
2.4k
Merge medio
3g 11h
PR unite (30g)
362

Descrizione

### Is your feature request related to a problem or challenge?

given a csv
```csv
mm/dd/yyyy,mm-dd-yyyy,dd/mm/yyyy,dd-mm-yyyy,yyyy/mm/dd,yyyy-mm-dd
01/01/2012,01-01-2012,01/01/2012,01-01-2012,2012/01/01,2012-01-01
02/02/2013,02-02-2013,02/02/2013,02-02-2013,2013/02/02,2013-02-02
03/03/2014,03-03-2014,03/03/2014,03-03-2014,2014/03/03,2014-03-03
04/04/2015,04-04-2015,04/04/2015,04-04-2015,2015/04/04,2015-04-04
05/05/2016,05-05-2016,05/05/2016,05-05-2016,2016/05/05,2016-05-05
06/06/2017,06-06-2017,06/06/2017,06-06-2017,2017/06/06,2017-06-06
07/07/2018,07-07-2018,07/07/2018,07-07-2018,2018/07/07,2018-07-07
```
currently only the last column will get converted to a `Date32`

```sql
❯ SELECT
arrow_typeof("mm/dd/yyyy") AS "mm/dd/yyyy",
arrow_typeof("mm-dd-yyyy") AS "mm-dd-yyyy",
arrow_typeof("dd/mm/yyyy") AS "dd/mm/yyyy",
arrow_typeof("dd-mm-yyyy") AS "dd-mm-yyyy",
arrow_typeof("yyyy/mm/dd") AS "yyyy/mm/dd",
arrow_typeof("yyyy-mm-dd") AS "yyyy-mm-dd"
from 'testdata/csv/dates.csv' limit 1;
+------------+------------+------------+------------+------------+------------+
| mm/dd/yyyy | mm-dd-yyyy | dd/mm/yyyy | dd-mm-yyyy | yyyy/mm/dd | yyyy-mm-dd |
+------------+------------+------------+------------+------------+------------+
| Utf8 | Utf8 | Utf8 | Utf8 | Utf8 | Date32 |
+------------+------------+------------+------------+------------+------------+
```

### Describe the solution you'd like

it'd be nice to auto detect more of these formats. I thought at the very least `YYYY/MM/DD` or `DD/MM/YYYY` would be valid as they are both extremely common.

### Describe alternatives you've considered

there really arent any good alternatives as there aren't any ergonomic ways to cast the utf8 field to date32 through the sql interface.

### Additional context

_No response_

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci il problema con l’esempio CSV e la query SQL di ispezione dei tipi mostrata nel report. Traccia l’inferenza delle date esistente del lettore CSV per la colonna yyyy-mm-dd e determina come distinguere i formati richiesti, soprattutto nei casi in cui giorno e mese siano ambigui. Il lavoro è completato quando i formati previsti vengono inferiti in modo coerente e sono coperti da test.

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

Valutazione

Stack tecnologico
rust
Ambito
data-engineering
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.