W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2009

Re: [TF-LIB] COALESCE is an unhelpful choice of name

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Fri, 13 Nov 2009 20:07:00 +0000
Message-ID: <4AFDBC64.8000201@talis.com>
To: Kjetil Kjernsmo <kjetil@kjernsmo.net>
CC: public-rdf-dawg@w3.org

On 13/11/2009 19:39, Kjetil Kjernsmo wrote:
> On Friday 13. November 2009 14:01:31 Andy Seaborne wrote:
>> I don't find the name COALESCE very helpful.
> I've been following the Semantics of SUM thread, since it looks like a
> problem I've had, but I feel I haven't really grokked what COALESCE is
> supposed to mean... So, I'll pose the stupid question: What is this suppose
> to do?
> Cheers,
> Kjetil

Good question -

In SQL, COALESCE return the first non-null from a list of expressions 
and columns.  I've used it when translating SPARQL to SQL to get the 
case of OPTIONAL, followed by OPTIONAL right.  I just tried it in MySQL 
and it masks errors as well.

SELECT COALESCE(null, 1/0 , 2) ;

| COALESCE(null, 1/0 , 2) |
|                  2.0000 |

(aside - system chosen name for the column)

but in PostgreSQL:

AFS=# SELECT COALESCE(null, 1/0, 2) ;
ERROR:  division by zero

(the system chosen name will be 'coalesce' always - even when used twice).

In SPARQL, we are using it for first bound value and now seem to be 
using it for first expression that evaluates without an error, MySQL- like


COALESCE(?x, 0) ==> 0
COALESCE(?x, ?y, 0) ==> "text"

COALESCE(?y, ?z) ==> "text"
COALESCE(1/?z, ?y) ==> "text"

We do seem to need some sort of protect-from-error form that returns a 
value and we have ended up with COALESCE.

Received on Friday, 13 November 2009 20:07:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:00:57 UTC