[
https://issues.apache.org/jira/browse/CASSANDRA-7395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14060120#comment-14060120
]
Robert Stupp commented on CASSANDRA-7395:
-----------------------------------------
Here's a new version of the patch. It's able to execute this command sequence:
It would be great if someone could take a look at the patch, because there are
some thing I'm not sure whether they are correct.
* All {{*Statement}} classes override {{execute()}} to return {{new
ResultMessage.Void();}}. If the default implementation in
{{SchemaAlteringStatement}} is called, at least cqlsh hangs (until it times
out).
* I'm not sure, whether schema agreement works they way I did it
* Separator for functions in bundles is currently ',' because otherwise cqlsh
fails to parse the whole {{create bundle}} statement (it splits at ';'
character)
* Currently only language {{CLASS}} works - which just means
{{Class.forName.getMethod}}
* Any general comments appreciated :)
{noformat}
create function double sin ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
create function double cos ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
create function double tan ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
drop function sin;
drop function cos;
drop function tan;
create bundle math {
function double sin ( input double ) as 'org.apache.cassandra.cql3.udf.DEMO'
};
create or replace bundle math {
function double sin ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO',
function double cos ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO',
function double tan ( input double ) as 'org.apache.cassandra.cql3.udf.DEMO'
};
create or replace bundle math {
function double sin ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO',
function double cos ( input double ) as 'org.apache.cassandra.cql3.udf.DEMO'
};
drop bundle math;
create function double sin ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
create function double cos ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
create function double tan ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO';
create or replace bundle math {
function double sin ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO',
function double cos ( input double ) as
'org.apache.cassandra.cql3.udf.DEMO',
function double tan ( input double ) as 'org.apache.cassandra.cql3.udf.DEMO'
};
CREATE KEYSPACE IF NOT EXISTS demo WITH REPLICATION = { 'class':
'SimpleStrategy', 'replication_factor': 2 };
create table demo.kv (
key int primary key,
value double
);
insert into demo.kv (key, value) values (1, 1);
insert into demo.kv (key, value) values (2, 2);
insert into demo.kv (key, value) values (3, 3);
select key, value, sin(value) from demo.kv;
select key, value, math::sin(value) from demo.kv;
{noformat}
> Support for pure user-defined functions (UDF)
> ---------------------------------------------
>
> Key: CASSANDRA-7395
> URL: https://issues.apache.org/jira/browse/CASSANDRA-7395
> Project: Cassandra
> Issue Type: New Feature
> Components: API, Core
> Reporter: Jonathan Ellis
> Labels: cql
> Fix For: 3.0
>
> Attachments: 7395.txt
>
>
> We have some tickets for various aspects of UDF (CASSANDRA-4914,
> CASSANDRA-5970, CASSANDRA-4998) but they all suffer from various degrees of
> ocean-boiling.
> Let's start with something simple: allowing pure user-defined functions in
> the SELECT clause of a CQL query. That's it.
> By "pure" I mean, must depend only on the input parameters. No side effects.
> No exposure to C* internals. Column values in, result out.
> http://en.wikipedia.org/wiki/Pure_function
--
This message was sent by Atlassian JIRA
(v6.2#6252)