Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#5799 closed defect (invalid)

min value for ogr datasource (shapefile) returns NULLs as minimum for 1.11.1 in Windows

Reported by: jcavner Owned by: warmerdam
Priority: high Milestone:
Component: default Version: 1.11.1
Severity: major Keywords:
Cc:

Description (last modified by jcavner)

NULLs are being treated as numeric (returns 0.0 and therfore NULLS are the minimum) when min is returned for a field on a shapefile in 1.11.1 in Windows Professional 7

Noted in QGIS https://hub.qgis.org/issues/11887

Change History (12)

comment:1 in reply to:  description Changed 7 years ago by jcavner

Description: modified (diff)

Replying to jcavner:

NULLs are being treated as numeric when min is returned in 1.11.1 in Windows

Noted in QGIS https://hub.qgis.org/issues/11887

comment:2 Changed 7 years ago by jcavner

Description: modified (diff)

comment:3 Changed 7 years ago by jcavner

Description: modified (diff)

comment:4 Changed 7 years ago by jcavner

Version: unspecified1.11.1

comment:5 Changed 7 years ago by Even Rouault

Sample shapefile and associated ogrinfo command line used demonstrating the issue would be useful.

comment:6 Changed 7 years ago by Jukka Rahkonen

At least sometimes NULL values of a numeric field is really stored as "0" into the .dbf file which does not natively support NULLs. See http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing_considerations_for_shapefile_output

Sample is welcome and meanwhile you can open the .dbf file with OpenOffice? or Excel and check how your NULLs appear there.

comment:7 Changed 7 years ago by mkuhn

Confirmed on Fedora 21 with GDAL 1.11.1

See my comment on QGIS for sample data and some test results.

comment:8 Changed 7 years ago by mkuhn

Sorry, the issue report is bogus.

Actually the sql sent to ogr was not properly executed and our fallback code failed to ignore NULL values. That's fixed in QGIS master.

Remaining issue is communication with OGR

ogrinfo lakes.shp -sql 'SELECT MIN("xlabel") FROM "lakes"'
INFO: Open of `lakes.shp'
      using driver `ESRI Shapefile' successful.
ERROR 1: Argument of column Summary Function 'MIN' should be a column.

Should the column name be unquoted?

comment:9 in reply to:  8 Changed 7 years ago by Even Rouault

Replying to mkuhn:

Sorry, the issue report is bogus.

Actually the sql sent to ogr was not properly executed and our fallback code failed to ignore NULL values. That's fixed in QGIS master.

Remaining issue is communication with OGR

ogrinfo lakes.shp -sql 'SELECT MIN("xlabel") FROM "lakes"'
INFO: Open of `lakes.shp'
      using driver `ESRI Shapefile' successful.
ERROR 1: Argument of column Summary Function 'MIN' should be a column.

Should the column name be unquoted?

Currently yes it seems that the OGR SQL parser doesn't support quote columns inside min() function, although it would be good to support it.

comment:10 Changed 7 years ago by mkuhn

Resolution: invalid
Status: newclosed

Done in https://github.com/qgis/QGIS/commit/790916b28ebd00d39c051eda352a4a093769e545

Would be nice to be able to revert this commit in the future.

comment:11 Changed 7 years ago by Jukka Rahkonen

There is at least one ticket (#4280)dealing with this and it is also included in the ideas of changes for GDAL 2.0 http://trac.osgeo.org/gdal/wiki/GDAL20Changes "More stricter OGR SQL syntax to distinguish literals from identifiers". I think that the idea is good but I would not be surprised if it would break something else in QGIS and other applications. Perhaps QGIS developers should make sort of a code review about where and how QGIS is making OGR-SQL requests.

Note: See TracTickets for help on using tickets.