cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Lerer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-10783) Allow literal value as parameter of UDF & UDA
Date Fri, 03 Jun 2016 09:01:09 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-10783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15313876#comment-15313876
] 

Benjamin Lerer commented on CASSANDRA-10783:
--------------------------------------------

{quote}
There is actually 2 commits: the first one allow things like {{SELECT 1 FROM ...}}, defaulting
{{1}} to be of type varint, much like in Robert's patch. Thinking about it though, I had a
slight change of heart and removed that behavior, making the query throw an error (saying
it can't infer the exact type). The reason is that I'm bothered with defaulting to varint
since it's partly random and not always the most convenient. So I figured, shouldn't we take
some more time to think about this and left it out initially. After all, it's not really a
big deal, {{SELECT 1 FROM...}} is not a very useful query and you can always do {{SELECT (int)1
FROM ...}} if you really want. But if people feel confident enough that defaulting to {{varint}}
is the only sensible choice and should be allowed now, then allowing it is as easy as ignoring
the 2nd commit on the branch.
{quote}

I am still not sure if we should allow {{SELECT 1 FROM ...}} or not but it seems to me that
we could probably do something better than defaulting to {{varint}}. As we also have the text
we can use it to narrow down the type to {{bigint}} or {{int32}}.

> Allow literal value as parameter of UDF & UDA
> ---------------------------------------------
>
>                 Key: CASSANDRA-10783
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10783
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL
>            Reporter: DOAN DuyHai
>            Assignee: Robert Stupp
>            Priority: Minor
>              Labels: CQL3, UDF, client-impacting, doc-impacting
>             Fix For: 3.x
>
>
> I have defined the following UDF
> {code:sql}
> CREATE OR REPLACE FUNCTION  maxOf(current int, testValue int) RETURNS NULL ON NULL INPUT

> RETURNS int 
> LANGUAGE java 
> AS  'return Math.max(current,testValue);'
> CREATE TABLE maxValue(id int primary key, val int);
> INSERT INTO maxValue(id, val) VALUES(1, 100);
> SELECT maxOf(val, 101) FROM maxValue WHERE id=1;
> {code}
> I got the following error message:
> {code}
> SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line
1:19 no viable alternative at input '101' (SELECT maxOf(val1, [101]...)">
> {code}
>  It would be nice to allow literal value as parameter of UDF and UDA too.
>  I was thinking about an use-case for an UDA groupBy() function where the end user can
*inject* at runtime a literal value to select which aggregation he want to display, something
similar to GROUP BY ... HAVING <filter clause>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message