[ https://issues.apache.org/jira/browse/CASSANDRA-11935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15310954#comment-15310954 ]
Benjamin Lerer commented on CASSANDRA-11935: -------------------------------------------- {quote} I don't believe in doing something for CQL because SQL does it and in particular, SQL allows pretty complicated query that we will never allow in CQL and don't want, which imply some things are less justified in CQL. We also tend to favor explicitness in C*/CQL. {quote} It is clear that there should be some differences between SQL and CQL. Nevertheless, SQL has been there for a long time and there are some areas where I believe we should learn from it. It does not make sense to me to have to write some thing like {{SELECT totalPrice / CAST(numberOfItems AS BIGINT)}} when we could simply write {{SELECT totalPrice / numberOfItem}} {quote} Also, the fact we've recently added specific explicit syntax for such conversion (CASSANDRA-10310) and are now saying some of it should be implicit make me worry that we're adding stuff to the type system without a good idea of the big picture. {quote} I do not believe that CAST and implicite conversion are not compatible. Each of them has its role. There are some case where you might want explicit casting like {{SELECT AVG(CAST (numberOfItems AS DOUBLE))}} and some other cases where you want implicite conversion. The big picture for me, in this area, is close from the one of most relational databases. I have use it for years and I always found it natural. I agree that we could make it work with explicit casting only but it will not be natural for the user as he will have to understand that numbers are typed and that you cannot add a simple integer to a double without doing an explicit cast. I have not worked on it yet but I do not believe that adding implicite conversion is complicated and I do think that it will simplify the life of the C* users. Specially if they come from an SQL background. > Add support for arithmetic operators > ------------------------------------ > > Key: CASSANDRA-11935 > URL: https://issues.apache.org/jira/browse/CASSANDRA-11935 > Project: Cassandra > Issue Type: Sub-task > Components: CQL > Reporter: Benjamin Lerer > Assignee: Benjamin Lerer > Fix For: 3.x > > > The goal of this ticket is to add support for arithmetic operators: > * {{-}}: Change the sign of the argument > * {{+}}: Addition operator > * {{-}}: Minus operator > * {{*}}: Multiplication operator > * {{/}}: Division operator > * {{%}}: Modulo operator > This ticket we should focus on adding operator only for numeric types to keep > the scope as small as possible. Dates and string operations will be adressed > in follow up tickets. > The operation precedence should be: > # {{*}}, {{/}}, {{%}} > # {{+}}, {{-}} > Some implicit data conversion should be performed when operations are > performed on different types (e.g. double + int). -- This message was sent by Atlassian JIRA (v6.3.4#6332)