Repository navigation
fix(clean): unisce per nome i parquet multi-file - #549
Merged
Merged
Conversation
Il ramo multi-file creava la view raw con read_parquet([...]) senza union_by_name: con due export dalla struttura diversa (es. serie storica + anno corrente della stessa fonte) DuckDB fallisce con "schema mismatch in glob" e il dataset non parte. Ora usa union_by_name=true, come fa gia' il ramo CSV. Per file con lo stesso schema il risultato e' identico; cambia solo il caso eterogeneo, che oggi nessun dataset del workspace usa (gli unici con 2+ parquet leggono una sola source o un path hardcoded in clean.sql). Caso reale: dcl-bologna / centraline_aria, che unisce centraline-qualita-aria (reftime/stazione/value/agente_atm) e dati-centraline-bologna-storico (cod_staz/agente/data_inizio/valore/um) per avere la serie oraria 2017-2026 in un solo dataset. Limite residuo, non toccato: il ramo con inject_column costruisce un UNION ALL posizionale di SELECT * per file, quindi schemi eterogenei + inject_column restano impossibili. Test: test_parquet_multi_file_different_schema_unions_by_name (fallisce senza il fix, passa con).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sintesi
Il ramo che legge più file parquet nella stessa view raw non passa
union_by_namea
read_parquet. Con due export della stessa fonte dalla struttura diversa il datasetnon parte: DuckDB risponde
schema mismatch in glob. Aggiuntounion_by_name=true,come già fa il ramo CSV.
Caso reale:
dcl-bologna/centraline_ariauniscecentraline-qualita-aria(
reftime/stazione/value/agente_atm) edati-centraline-bologna-storico(
cod_staz/agente/data_inizio/valore/um) per avere la serie oraria 2016-2026 in unsolo dataset. Prima del fix:
Binder Error: schema mismatch in glob. Dopo: runcompleta con
status: passed, 763.032 righe clean, readiness 8/8.Contesto collegato
Nessuna issue: bug trovato a valle mentre si costruiva il dataset sopra. Se preferite
tracciarlo, lo apro e lo collego.
Cosa cambia
Impatto su contratti pubblici
Nessuno. Cambia solo il caso eterogeneo; con file dallo stesso schema
union_by_nameproduce lo stesso risultato (DuckDB allinea per nome). Nessun campo di
dataset.yml,nessun path, nessuno schema parquet, nessuna firma pubblica toccata.
Verifica
Test aggiunto con marker
contract:test_parquet_multi_file_different_schema_unions_by_name. Verificato che falliscesenza il fix (
'um'mancante nella union) e passa con.End-to-end:
dcl-bologna/centraline_aria, run 2016-2026 su root pulita,passed.pytest -m corepassa (suite completa verde)ruff check .passamypy toolkit/passacontractChecklist PR
Note per chi revisiona
dataset.ymldel workspace (68 con ≥2source o
inject_column). I 15 dataset coninject_columnsono tutti CSV e nonpassano da questo ramo. Gli unici con 2+ parquet sono
centraline-aria(questo caso)e
fabbisogno-settoriale, che usamode: lateste legge il secondo parquet con unpath hardcoded dentro
clean.sql. Quindi oggi il ramo multi-file eterogeneo non èusato da nessuno: il fix abilita un caso nuovo, non cambia output esistenti.
inject_columncostruisce unUNION ALLposizionale diSELECT *per file, quindiinject_column+ schemieterogenei resta impossibile. Servirebbe un allineamento esplicito delle colonne ed è
un disegno a sé: l'ho lasciato fuori dal perimetro.
_execute_parquet_read; il ramo CSV aveva già la stessa logica(
use_union), quindi il fix allinea i due percorsi.