[gdal-dev] ogr2ogr: new layer called "SELECT" after SQLITE query

Even Rouault even.rouault at spatialys.com
Fri Dec 27 11:18:46 PST 2019


On vendredi 27 décembre 2019 19:22:01 CET Jakob Miksch wrote:
> Dear list,
> 
> I found a unexpected behavior of the SQLITE dialect. See this example
> where I access ten features of a remote GeoJSON:
> 
> ogr2ogr \
>    -dialect SQLITE \
>    -sql "SELECT * FROM chapters LIMIT 10" \
>    -f GPKG output.gpkg \
> https://raw.githubusercontent.com/maptime/maptime.github.io/master/_data/cha
> pters.json
> 
> The resulting layername with SQLITE dialect is "SELECT". In contrast,
> with OGRSQL dialect, the resulting layername is "chapters" - which is
> more logical to me.
> 
> Any ideas why this behavior is different between SQLITE and OGRSQL dialect?

OGRSQL parses the SQL, so it knows the SQL is about selecting in a given 
layer.
In the SQLite case, the SQL is mostly forwarded to SQLite and we don't really 
try if we select from a single layer, or do something more complicated like a 
join etc

Adding "-nln chapers" will make it work as you expect.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list