feat(scaffold): scaffolding CKAN via DataStore schema (#363)#408
Merged
Conversation
c4ebc4e to
0cdb667
Compare
0cdb667 to
74b1e1a
Compare
CKAN DataStore numeric = PostgreSQL NUMERIC(p,s) che ammette decimali. TRY_CAST(x AS BIGINT) tronca 12.34 a 12 — perdita dati silenziosa. TRY_CAST(x AS DOUBLE) mantiene 12.34. Fix in _map_datastore_type e test relativi.
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.
Descrizione
Lo scaffold CKAN attuale (
_scaffold_ckan->_scaffold_minimal_ckan) scarica il CSV per profilare colonne e tipi. Se il download fallisce (auth, redirect, formati misti), produce unclean.sqlconSELECT * FROM raw_input.Con questa PR, se la risorsa CKAN ha
datastore_active=True, lo scaffold chiamadatastore_search?limit=0e genera colonne mappate senza scaricare nulla. Il fallback trasparente garantisce che per i portali senza DataStore (es.dati.gov.it) il comportamento resta invariato.Modifiche
toolkit/scout/http.pydiscover_ckan_resourcesincludedatastore_active; nuovafetch_ckan_datastore_schema()toolkit/scaffold/clean.py_map_datastore_type()eprofile_from_datastore()per tradurre fields DataStore in profiletoolkit/cli/cmd_scout.py_scaffold_ckan()tenta DataStore prima del download CSVtoolkit/scout/__init__.pyfetch_ckan_datastore_schemaTest
test_scout_datastore.py— 11 test contrattuali (discover con datastore_active, fetch_ckan_datastore_schema con mock)test_scaffold_clean.py— 24 test pure_unit (_map_datastore_type parametrizzato 20 casi, profile_from_datastore, integrazione con generate_clean_sql)DATA_UDIENZA->DATE), MUR (9 colonne)Verifica
pytest tests/test_scout_datastore.py tests/test_scaffold_clean.py -v # 35 passedCopertura portali
clean.sqlcon colonne mappateclean.sqlcon colonne mappateclean.sqlcon colonne mappateCloses #363