MagicStack / MagicStack/asyncpg
copy_from_query drops headers if any postgis NOTICE/LOCATION messages produced
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 468
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
when using Connection.copy_from_query I had a statement which eventually resolved to something like:
COPY (
select 1
from field_year_crop_variety_layer fycvl
cross join filters
join field_meta fm on
fm.field_id = fycvl.field_id and
(filters.filter_geometry is null or st_intersects(filters.filter_geometry, fm.centroid))
order by fycvl.field_id, fycvl.harvest_year, fycvl.layer_id, fycvl.crop, fycvl.variety
limit '100000'::int
) TO STDOUT (FORMAT 'csv', HEADER True)
where filter_geometry is a geometry, and fm.centroid is a geography.
and no matter what I did asyncpg would not return the headers. It wasn't until I broke it down and ran it from psql that I noticed the output:
field_id,harvest_year,layer_id,crop,variety,is_precision_data,date_period,avg_date,data_is_missing,missing_data_message,crop_variety_layer_area_m2,geometry,computed_at
NOTICE: 00000: Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY
LOCATION: geography_from_geometry, geography_inout.c:510
NOTICE: 00000: Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY
LOCATION: geography_from_geometry, geography_inout.c:510
143011,2017,0,corn,unknown,t,"[2017-04-25,2017-04-26)",2017-04-24,f,,7240.833,,1752130305.616610
sure enough, if I fixed the bug (casting fm.centroid to a geometry) the headers appeared. This seems like a bug in asyncpg when interpreting the data returned.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con Connection.copy_from_query e riproduci la query COPY fornita su PostgreSQL con i messaggi NOTICE/LOCATION di PostGIS abilitati. Traccia come vengono gestiti questi messaggi insieme all'output di COPY; l'attività è completata quando i dati restituiti conservano la propria intestazione CSV quando vengono prodotti messaggi di questo tipo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python
- 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