#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 )
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 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
Description: | modified (diff) |
---|
comment:3 by , 9 years ago
Description: | modified (diff) |
---|
comment:4 by , 9 years ago
Version: | unspecified → 1.11.1 |
---|
comment:5 by , 9 years ago
Sample shapefile and associated ogrinfo command line used demonstrating the issue would be useful.
comment:6 by , 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 , 9 years ago
Confirmed on Fedora 21 with GDAL 1.11.1
See my comment on QGIS for sample data and some test results.
follow-up: 9 comment:8 by , 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?
comment:9 by , 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 , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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 , 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.
comment:12 by , 9 years ago
REPACK (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L137) CREATE SPATIAL INDEX (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L1353) DROP INDEX (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L1367) CREATE INDEX (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L1369) SELECT DISTINCT (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L2309) SELECT MIN (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L2350) SELECT MAX (https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L2389) SELECT * FROM
Replying to jcavner: