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

Tyler Hobbs commented on CASSANDRA-7526:
----------------------------------------

I played around with this a bit, and one thing I noticed is that javascript 
seems to be incapable of returning an Integer (or Long) object.  You only get 
Doubles back.  I suspect other scripting languages may have similar problems.

Perhaps we should automatically attempt to convert the returned object to the 
return type, at least for types where that makes sense?

Also, you should still catch LinkageError in JavaSourceBasedUDF, since it's not 
a subclass of RuntimeException.  (A unit test is failing due to that.)

> Defining UDFs using scripting language directly from CQL
> --------------------------------------------------------
>
>                 Key: CASSANDRA-7526
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7526
>             Project: Cassandra
>          Issue Type: New Feature
>            Reporter: Sylvain Lebresne
>            Assignee: Robert Stupp
>             Fix For: 3.0
>
>         Attachments: 7526.txt, 7526v2.txt, 7526v3.txt, 7526v4.txt
>
>
> In CASSANDRA-7395 we'll introduce the ability to define user functions by 
> dropping a java class server side. While this is a good first step and a good 
> option to have in any case, it would be nice to provide a simpler way to 
> define those functions directly from CQL. And while we probably don't want to 
> re-invent a new programming language inside CQL, we can reuse one. Typically, 
> with java 8, we could use nashorn. This would allow a syntax along the lines 
> of:
> {noformat}
> CREATE FUNCTION sum (a bigint, b bigint) bigint AS { return a + b; }
> {noformat}
> Note that in this, everything before the AS will be parsed by us, which we'll 
> probably want because we'll probably need to have the types of 
> arguments/return in practice anyway, and it's a good idea to reuse CQL types. 
> The expression after the AS will be given to Nashorn however.
> Please note that in theory we could ultimately support multiple language 
> after the AS. However, I'd like to focus on supporting just one for this 
> ticket and I'm keen on using javascript through Nashorn because as it's the 
> one that will ship with java from now on, it feels like a safe default.



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

Reply via email to