Count, plus phasing out of query.

3 views
Skip to first unread message

Robin Barooah

unread,
Feb 25, 2009, 10:46:52 PM2/25/09
to Sublime SimpleDB
Hi,

Amazon has decided to phase out the 'Query' language in favor of
focussing purely on select.

Apparently the word 'select' makes people feel as thought they are not
locked in to simpleDB, even though the query syntax is not sql, and
the semantics are different from a relational database.

Oh well.

I have implemented a new version of the DSL on top of 'select'. It
turns out that there is almost no difference in practice. I haven't
attempted to fake out an actual 'select * from ...'. I played with
that for a while, but it seemed to cause a whole load of headaches for
no benefit other than including the word 'select'.

Instead, queries stills start from a domain - e.g:

val found = domain("users") where (name is "atlas")

or:

val users = domain("users")
val found = users (name is "atlas")
val ordered = users ((name is "robin") order_by (date))

the count 'pseudo-function' is supported:

val numUsers:int = domain("users") count

or

val users = domain("users")
val numPersonalities:int = users count (name is "robin")

as is the 'like' operator

val found = domain("users") where (name like "lando%")

and the usual conjunctions

val found = domain ("users") where ((name like "lando%) intersection
(planet is "bespin"))

I moved the typed attributes code into 'org.sublime.Attributes' and
the conversions to 'org.sublime.Conversions' since they have more
general application. For now the query DSL is still available.

I also renamed eq and ne to is and is_not. eq is defined on anyref
and overriding it for this purpose seemed like a mistake. Also, I am
now using implicits to apply the operators to the attributes, and this
wasn't working with eq because of its existing definition.

Code that uses the query DSL should work with only minor changes:

Imports -

import org.sublime.Attributes._
import org.sublime.Conversions._
import org.sublime.amazon.simpleDB.Select._
import org.sublime.amazon.simpleDB.api._

Change eq to is, ne to is_not, and sort to order_by.

-Robin

Landon Fuller

unread,
Mar 2, 2009, 9:41:47 PM3/2/09
to sublime-...@googlegroups.com
On Feb 25, 2009, at 7:46 PM, Robin Barooah wrote:

> I have implemented a new version of the DSL on top of 'select'. It
> turns out that there is almost no difference in practice. I haven't
> attempted to fake out an actual 'select * from ...'. I played with
> that for a while, but it seemed to cause a whole load of headaches for
> no benefit other than including the word 'select'.

Thanks for putting this together.
I just migrated to the new select support, and ran across one issue
with select <attributes ...> from syntax.

The select attribute syntax documentation reads:
"An explicit list of attributes (attribute1,..., attributeN)"

However, the parenthesis are used only for punctuation within the
documentation, and the actual select statement should be sent
unadorned:
select attribute1, attribute2 from ...

I've posted my patch here:
http://github.com/landonf/simpledb-scala-binding-patches/commit/45c20b2756d331de2f6fd135eed8e9e1d45db136

-landonf

PGP.sig

Robin

unread,
Mar 2, 2009, 10:50:12 PM3/2/09
to sublime-...@googlegroups.com
oops - I did wonder about that - but looks like I forgot to test it after making that change somewhere along the way

unit tests will probably be forthcoming now that I'm settling on the select API.

-Robin
--
-Robin

Robin Barooah
http://www.sublime.org

Robin

unread,
Mar 2, 2009, 10:50:20 PM3/2/09
to sublime-...@googlegroups.com
And thanks!

On Mon, Mar 2, 2009 at 6:41 PM, Landon Fuller <lan...@plausible.coop> wrote:

--
-Robin

Robin Barooah
http://www.sublime.org
Sent from: San francisco CA United States.
Reply all
Reply to author
Forward
0 new messages