Opened 16 years ago

Closed 16 years ago

#2171 closed enhancement (fixed)

Support for OGR SQL type cast and field name alias

Reported by: tamas Owned by: 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 (6)

ogr-sql.patch (11.8 KB ) - added by tamas 16 years ago.
Update the patch to reflect the RFC changes
veg_points.shp (1.6 KB ) - added by dylan 16 years ago.
test data
veg_points.shx (532 bytes ) - added by dylan 16 years ago.
test data
veg_points.dbf (713 bytes ) - added by dylan 16 years ago.
test data
veg_points.prj (428 bytes ) - added by dylan 16 years ago.
test data
veg_points.gpx (4.8 KB ) - added by tamas 16 years ago.
ogr2ogr result

Download all attachments as: .zip

Change History (15)

comment:1 by tamas, 16 years ago

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

by tamas, 16 years ago

Attachment: ogr-sql.patch added

Update the patch to reflect the RFC changes

comment:2 by tamas, 16 years ago

Applied in r13721

comment:3 by warmerdam, 16 years ago

Cc: warmerdam added
Description: modified (diff)
Keywords: sql added

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

comment:4 by tamas, 16 years ago

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

comment:5 by dylan, 16 years ago

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.

by dylan, 16 years ago

Attachment: veg_points.shp added

test data

by dylan, 16 years ago

Attachment: veg_points.shx added

test data

by dylan, 16 years ago

Attachment: veg_points.dbf added

test data

by dylan, 16 years ago

Attachment: veg_points.prj added

test data

by tamas, 16 years ago

Attachment: veg_points.gpx added

ogr2ogr result

in reply to:  5 ; comment:6 by tamas, 16 years ago

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 comment:7 by dylan, 16 years ago

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.

comment:8 by dylan, 16 years ago

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

comment:9 by tamas, 16 years ago

Resolution: fixed
Status: newclosed

I believe this ticket can be closed for now.

Note: See TracTickets for help on using tickets.