OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.8k stars 2.51k forks source link

Add symmetric "EXCLUDE"..."HIDDEN" example #10850

Closed jidanni closed 1 week ago

jidanni commented 1 week ago

Feature description

On https://gdal.org/en/latest/user/ogr_sql_dialect.html

SELECT *, 'BRUSH(fc:#01234567)' AS OGR_STYLE FROM source_layer

works fine.

But below it, in addition to just saying,

SELECT * EXCLUDE(my_style_field), my_style_field AS OGR_STYLE HIDDEN FROM source_layer

please also to be sure to use that additional syntax upon the earlier example:

SELECT * EXCLUDE('BRUSH...

Else it is really hard to make sure one gets all the quoting right.

Not related to https://github.com/OSGeo/gdal/issues/8668#issuecomment-2121680163 version issues.

rouault commented 1 week ago

Else it is really hard to make sure one gets all the quoting right.

The 2 examples are distinct. I don't feel we need to do anything else here.

jratike80 commented 1 week ago

The 'BRUSH(fc:#01234567)' thing is "string literal", a string that is given directly with SQL instead of reading it from the database. This kind of fields cannot be excluded and select * does not select it either.

I guess that you'll get what you want simply with this:

ogrinfo -sql "select *, 'BRUSH(fc:#01234567)' as OGR_STYLE HIDDEN from minimal" minimal.jml

jidanni commented 1 week ago

Well all this needs to be mentioned there on the document.

As the user will plug example A into example B, which won't work.

jratike80 commented 1 week ago

The 'string' as OGR_STYLE thing is basic SQL, similar to select 2+3 as sum that makes 5. I know that GDAL users can make working queries with simple SQL by examples without knowing anything about the language, but for my mind learning SQL by the ogr2ogr usage examples is not the right route.