wiki:rfc28_sqlfunc

Version 1 (modified by warmerdam, 14 years ago) ( diff )

--

RFC 28: OGR SELECT Functions

Author: Frank Warmerdam
Contact: warmerdam@…
Status: Development

Summary

The OGR SQL evaluation engine currently does not allow general purpose functions to be applied to columns in SELECT statements. Some special purpose functions are supported (ie. CAST, COUNT, AVG, MAX, MIN, and SUM), but not as part of more general expressions and generally in very constrained arrangements. It is the intent of this work item to extend the OGR SQL engine to support fairly general purpose expression evaluation in the output field list of OGR SQL SELECT statements and to implement a few preliminary processing functions in a fashion compatible with standard SQL. For example, after implementation it is intended the following could be evaluated.

SELECT CONCAT(first_name, ' ', last_name) AS full_name FROM customers
SELECT id, "Regional Road" AS roadtypename FROM roads where roadtype=3
SELECT (subtotal+salestax) as totalcost from invoice_info

Technical Approach

... to be filled in, but the intention is that the existing expression evaluation engine for the WHERE clause would be extended and used also on the SELECT field generation side.

It should be noted that as a side effect WHERE clauses will also support more general expressions - not just logical comparisons. For instance:

SELECT * WHERE (subtotal+salestax) > 100.0

New Functions

  • Math: +, -, *, /,
  • String: CONCAT

Compatability Implications

There are no anticipated backward compatability problems. For the most part the change results in some OGR SQL statements to work that would previously have generated an error.

Implementation Plan

Frank Warmerdam will implement, test and document for the GDAL/OGR 1.8 release.

Testing

Documentation

Note: See TracWiki for help on using the wiki.