Ticket #2171 (new enhancement)

Opened 6 months ago

Last modified 4 months ago

Support for OGR SQL type cast and field name alias

Reported by: tamas Assigned to: tamas
Priority: normal Milestone: 1.6.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: sql
Cc: warmerdam

Description (Last modified by warmerdam)

These changes will support to change the name and the type of the fields in the results of the OGR SQL query. A patch will be attached with the implementation details.

I suspect gdal/ogr/ogr_sql.dox still needs to be updated to reflect this change.

Attachments

ogr-sql.patch (11.8 kB) - added by tamas on 01/26/08 16:14:21.
Update the patch to reflect the RFC changes
veg_points.shp (1.6 kB) - added by dylan on 03/04/08 17:37:55.
test data
veg_points.shx (0.5 kB) - added by dylan on 03/04/08 17:38:05.
test data
veg_points.dbf (0.7 kB) - added by dylan on 03/04/08 17:38:12.
test data
veg_points.prj (428 bytes) - added by dylan on 03/04/08 17:38:17.
test data
veg_points.gpx (4.8 kB) - added by tamas on 03/05/08 06:38:31.
ogr2ogr result

Change History

01/26/08 16:13:15 changed by tamas

The corresponding RFC can be found here: http://trac.osgeo.org/gdal/wiki/rfc21_ogrsqlcast

01/26/08 16:14:21 changed by tamas

  • attachment ogr-sql.patch added.

Update the patch to reflect the RFC changes

02/07/08 08:18:26 changed by tamas

Applied in r13721

02/27/08 23:07:02 changed by warmerdam

  • keywords set to sql.
  • cc set to warmerdam.
  • description changed.

I have added a minimal sort of sql cast operator test in ogr_sql_test.py as r13888 in trunk.

02/28/08 05:43:09 changed by tamas

I've modified ogr_sql.dox to reflect the changes r13889

(follow-up: ↓ 6 ) 03/04/08 17:37:27 changed by dylan

I have noticed that it is not possible to use the 'AS' construct within an SQL argument to ogr2ogr.

Here is the incantation: ogr2ogr -t_srs '+proj=latlong +datum=WGS84' \ -f GPX -dsco GPX_USE_EXTENSIONS=YES \ veg_points.gpx veg_points.shp \ -sql "SELECT cat AS name FROM veg_points"

The data involved is attached.

03/04/08 17:37:55 changed by dylan

  • attachment veg_points.shp added.

test data

03/04/08 17:38:05 changed by dylan

  • attachment veg_points.shx added.

test data

03/04/08 17:38:12 changed by dylan

  • attachment veg_points.dbf added.

test data

03/04/08 17:38:17 changed by dylan

  • attachment veg_points.prj added.

test data

03/05/08 06:38:31 changed by tamas

  • attachment veg_points.gpx added.

ogr2ogr result

(in reply to: ↑ 5 ; follow-up: ↓ 7 ) 03/05/08 06:41:17 changed by tamas

I've tried this using the trunk on Windows but it have been working the result attached. Might it be a platform dependent issue?

Tamas

Replying to dylan:

I have noticed that it is not possible to use the 'AS' construct within an SQL argument to ogr2ogr. Here is the incantation: ogr2ogr -t_srs '+proj=latlong +datum=WGS84' \ -f GPX -dsco GPX_USE_EXTENSIONS=YES \ veg_points.gpx veg_points.shp \ -sql "SELECT cat AS name FROM veg_points" The data involved is attached.

(in reply to: ↑ 6 ) 03/05/08 12:28:39 changed by dylan

It looks like it works for Tamas on Windows. I am using Linux x86, and here is the output from svn info:

URL: http://svn.osgeo.org/gdal/branches/1.5
Repository Root: http://svn.osgeo.org/gdal
Repository UUID: f0d54148-0727-0410-94bb-9a71ac55c965

Am I not using the latest and greatest GDAL?

Replying to tamas:

I've tried this using the trunk on Windows but it have been working the result attached. Might it be a platform dependent issue? Tamas Replying to dylan:

I have noticed that it is not possible to use the 'AS' construct within an SQL argument to ogr2ogr. Here is the incantation: ogr2ogr -t_srs '+proj=latlong +datum=WGS84' \ -f GPX -dsco GPX_USE_EXTENSIONS=YES \ veg_points.gpx veg_points.shp \ -sql "SELECT cat AS name FROM veg_points" The data involved is attached.

03/05/08 12:40:31 changed by dylan

Apologies- I was using the 1.5 stable branch. I can confirm the this functionality works on x86 Linux with GDAL-trunk. Thanks.