DESCRIPTION

JCBC-755: implement rest of N1QL tutorial and adapt DSL

Motivation
----------
Continuing work from JCBC-750, implementing rest of the steps from the
N1QL tutorial into SelectDslSmokeTest, and adding missing operators or
functions in the DSL along the way. Note that 3 steps make use of DML
which will be covered later.

Modifications
-------------
Added remaining steps from tutorial to smoke tests.

GroupByPath can now directly use identifiers in String form.

Modified KeyPath so that distinction between a String constant key vs an
identifier key is more explicit (constant keys: xxxKeysValues methods).

Added sum and distinct functions in AggregateFunctions.

Added DateFunctions (with strToMillis, datePartStr), NumberFunctions
(moved round there from Functions), StringFunctions (with lower and
substr).

In Expression, added x method to convert a statement, sub method to
convert a statement as a sub-statement between parenthesis, path method
to construct a path from Expressions separated with dots.
Added arithmetic operators add, subtract, multiply and divide.

Added a Case mini-DSL for case and case search expressions
(eg. CASE a.id WHEN b.subid THEN 1 ELSE 0 END).

Removed Functions class (all have been moved in xxxFunctions classes in
the functions package).

Marked various DSL classes as @Experimental xxx@xxx.xxx

Results
-------
Except for tutorial steps where DML is used, all steps are covered by
the SelectDslSmokeTest.

Change-Id: I5a71614c6d8beb6a8de0b94c086d3c68c66bf91b


COMMENTS

author: Estrella Humphrey
date: 2015-04-23 14:50:55.221000000

Uploaded patch set 3.

-------------------------------------
author: Estrella Humphrey
date: 2015-04-23 15:23:43.816000000

Patch Set 3:

(3 comments)

case search syntax was changed in this patchset for better readability without loosing correctness. I am open to alternative namings for initial factory methods (caseSearch, caseSimple) but note that case and else are java keywords so not an option ;)

Line:384, src/test/java/com/couchbase/client/java/query/dsl/SelectDslSmokeTest.java -> these are skipped pending a more complex DML support in the DSL

Line:567, src/test/java/com/couchbase/client/java/query/dsl/SelectDslSmokeTest.java -> arithmetics in action

Line:634, src/test/java/com/couchbase/client/java/query/dsl/SelectDslSmokeTest.java -> case search construct

-------------------------------------
author: Estrella Humphrey
date: 2015-04-23 15:35:15.356000000

Patch Set 3:

will open a ticket to add more tests / full coverage for the new DSL elements

-------------------------------------
author: Estrella Humphrey
date: 2015-04-23 15:35:23.626000000

Patch Set 3: Verified+1

-------------------------------------
author: Natasha Sullivan
date: 2015-04-24 08:35:01.497000000

Patch Set 3: Code-Review-1

(5 comments)

minor improvements, otherwise great

Line:35, src/main/java/com/couchbase/client/java/query/dsl/functions/Case.java -> stability annotations

Line:45, src/main/java/com/couchbase/client/java/query/dsl/functions/NumberFunctions.java -> can you add double and float here as well? Since this is what people want to round mostly I guess

Line:162, src/main/java/com/couchbase/client/java/query/dsl/Expression.java -> is null and empty the same for this case? since null would be NULL and not an empty string or something - just double checking.

Line:1687, src/main/java/com/couchbase/client/java/query/dsl/Expression.java -> in addition to Number, I think we should support (like with the other methods here - all the overloads? int, long,...

same on the other methods

Line:45, src/main/java/com/couchbase/client/java/query/dsl/functions/MetaFunctions.java -> let's support strings here too for convenience like meta("id")

-------------------------------------
author: Estrella Humphrey
date: 2015-04-24 09:09:10.934000000

Patch Set 3:

(5 comments)

Line:35, src/main/java/com/couchbase/client/java/query/dsl/functions/Case.java -> Done

Line:45, src/main/java/com/couchbase/client/java/query/dsl/functions/NumberFunctions.java -> Done

Line:162, src/main/java/com/couchbase/client/java/query/dsl/Expression.java -> you're right... it's a degenerative case anyway, both empty and null make no real sense when constructing a path... but maybe it's better to just return an empty expression in this case?

Line:1687, src/main/java/com/couchbase/client/java/query/dsl/Expression.java -> since arithmetics only make sense for expressions and numerical constants, Number covers all the later in one go thanks to autoboxing ;)

eg. x("user.age").divide(30).subtract("user.id").multiply(12.3f).add(100L)
gives
user.age / 30 - user.id * 12.3 + 100

(note: we could migrate other numerical overloads to a single Number one as well)

Line:45, src/main/java/com/couchbase/client/java/query/dsl/functions/MetaFunctions.java -> Done

-------------------------------------
author: Tate Garrett
date: 2015-04-24 09:16:50.766000000

Change has been successfully cherry-picked as 0896e44936c3bb26376b5bf1cafe7efd3282a996

-------------------------------------
