Opened 9 years ago

Closed 9 years ago

Last modified 9 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)

in reply to:  description comment:1 by jcavner, 9 years ago

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 by jcavner, 9 years ago

Description: modified (diff)

comment:3 by jcavner, 9 years ago

Description: modified (diff)

comment:4 by jcavner, 9 years ago

Version: unspecified1.11.1

comment:5 by Even Rouault, 9 years ago

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

comment:6 by Jukka Rahkonen, 9 years ago

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 by mkuhn, 9 years ago

Confirmed on Fedora 21 with GDAL 1.11.1

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

comment:8 by mkuhn, 9 years ago

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?

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

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 by mkuhn, 9 years ago

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 by Jukka Rahkonen, 9 years ago

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.