Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 59673 invoked from network); 17 Nov 2005 00:51:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Nov 2005 00:51:49 -0000 Received: (qmail 59103 invoked by uid 500); 17 Nov 2005 00:51:48 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 59092 invoked by uid 99); 17 Nov 2005 00:51:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2005 16:51:48 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.36] (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2005 16:53:22 -0800 Received: from fe-amer-10.sun.com ([192.18.108.184]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id jAH0pQD7020554 for ; Wed, 16 Nov 2005 17:51:27 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0IQ200701Q9K6V00@mail-amer.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Wed, 16 Nov 2005 17:51:26 -0700 (MST) Received: from [192.168.0.10] ([24.6.172.77]) by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0IQ200G2ZQDOM6YD@mail-amer.sun.com> for jdo-dev@db.apache.org; Wed, 16 Nov 2005 17:51:24 -0700 (MST) Date: Wed, 16 Nov 2005 16:51:22 -0800 From: Craig L Russell Subject: Negative VOTE Issue 143: Aggregating null-valued expressions Sender: Craig.Russell@Sun.COM To: JDO Expert Group , Apache JDO project Message-id: <52E63249-B46E-4764-B62C-923DB281B0AA@sun.com> MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/alternative; boundary="Boundary_(ID_odV7E9INd+z86F1+VVYWBA)" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Boundary_(ID_odV7E9INd+z86F1+VVYWBA) Content-type: text/plain; format=flowed; delsp=yes; charset=US-ASCII Content-transfer-encoding: 7BIT Javadogs, Please comment if you have any issues with the proposal. Issue 143 H Treatment of null values in JDOQL COUNT JDOQL currently says nothing about the treatment of null values in the COUNT clause of a query. Based on the SQL treatment, and the fact that JDOQL is intended to be executed by the back end datastore (see below) I propose adding this to the JDOQL chapter: If null values are aggregated, they do not participate in the aggregate result. If all of the expressions to be aggregated evaluate to null, the result is the same as if there were no instances that match the filter. The behavior of aggregates is described in Part 2 of the ANSI spec, section 10.9. 1) A null column is excluded from a COUNT( colName ) aggregate. This is described in the section 10.9 under General Rules 4a. The database is supposed to raise a warning: "warning--null value eliminated in set function" 2) Unless you specify the DISTINCT keyword, the COUNT aggregate will not filter out duplicates. Each row, regardless of whether it is a duplicate, will go into the tally. This is described in the same section underGeneral Rules 4b. For the record, Derby exhibits this ANSI behavior. To summarize: -- the following query eliminates rows with null in column "a" select count( a ) from foo; -- the following query eliminates rows with null in column "a" -- and eliminates duplicates select count( distinct a ) from foo; Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Boundary_(ID_odV7E9INd+z86F1+VVYWBA)--