You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2014/08/21 14:20:52 UTC
git commit: Fix parsing of UDF body
Repository: cassandra
Updated Branches:
refs/heads/trunk 5ec10197f -> f7cb008ce
Fix parsing of UDF body
patch by snazy; reviewed by slebresne for CASSANDRA-7740
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f7cb008c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f7cb008c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f7cb008c
Branch: refs/heads/trunk
Commit: f7cb008ceb0983bab4ec982dde4816e6c50b97e6
Parents: 5ec1019
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Aug 21 14:19:52 2014 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Thu Aug 21 14:20:46 2014 +0200
----------------------------------------------------------------------
CHANGES.txt | 2 +-
pylib/cqlshlib/cql3handling.py | 26 +++++++++++++++++++++++++-
src/java/org/apache/cassandra/cql3/Cql.g | 13 ++++++++-----
3 files changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f7cb008c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b631a9a..2466a01 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,7 +1,7 @@
3.0
* Do anticompaction in groups (CASSANDRA-6851)
* Verify that UDF class methods are static (CASSANDRA-7781)
- * Support pure user-defined functions (CASSANDRA-7395)
+ * Support pure user-defined functions (CASSANDRA-7395, 7740)
* Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
* Move sstable RandomAccessReader to nio2, which allows using the
FILE_SHARE_DELETE flag on Windows (CASSANDRA-4050)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f7cb008c/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index bf9088e..38aa8d8 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -46,7 +46,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
'select', 'from', 'where', 'and', 'key', 'insert', 'update', 'with',
'limit', 'using', 'use', 'count', 'set',
'begin', 'apply', 'batch', 'truncate', 'delete', 'in', 'create',
- 'keyspace', 'schema', 'columnfamily', 'table', 'index', 'on', 'drop',
+ 'function', 'keyspace', 'schema', 'columnfamily', 'table', 'index', 'on', 'drop',
'primary', 'into', 'values', 'timestamp', 'ttl', 'alter', 'add', 'type',
'compact', 'storage', 'order', 'by', 'asc', 'desc', 'clustering',
'token', 'writetime', 'map', 'list', 'to', 'custom', 'if', 'not'
@@ -232,6 +232,7 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
| <createColumnFamilyStatement>
| <createIndexStatement>
| <createUserTypeStatement>
+ | <createFunctionStatement>
| <dropKeyspaceStatement>
| <dropColumnFamilyStatement>
| <dropIndexStatement>
@@ -981,6 +982,25 @@ syntax_rules += r'''
( "," [newcolname]=<cident> <storageType> )*
")"
;
+
+<createFunctionStatement> ::= "CREATE" ("OR" "REPLACE")? "FUNCTION"
+ ("IF" "NOT" "EXISTS")?
+ ("NON"? "DETERMINISTIC")?
+ ( namespace=<nonSystemKeyspaceName> dot="::" )? function=<cfOrKsName>
+ ( "(" ( newcol=<cident> <storageType>
+ ( "," [newcolname]=<cident> <storageType> )* )?
+ ")" )?
+ "RETURNS" <storageType>
+ (
+ ("LANGUAGE" <cident> "AS"
+ (
+ <stringLiteral>
+ )
+ )
+ | (<stringLiteral>)
+ )
+ ;
+
'''
explain_completion('createIndexStatement', 'indexname', '<new_index_name>')
@@ -1012,6 +1032,10 @@ syntax_rules += r'''
<dropUserTypeStatement> ::= "DROP" "TYPE" ut=<userTypeName>
;
+<dropFunctionStatement> ::= "DROP" "FUNCTION" ("IF" "EXISTS")?
+ ( namespace=<nonSystemKeyspaceName> dot="." )? function=<cfOrKsName>
+ ;
+
'''
@completer_for('indexName', 'ksname')
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f7cb008c/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g
index 96a668b..d44fc7c 100644
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@ -514,7 +514,14 @@ createFunctionStatement returns [CreateFunctionStatement expr]
rt=comparatorType
(
( { language="CLASS"; } cls = STRING_LITERAL { bodyOrClassName = $cls.text; } )
- | ( K_LANGUAGE l = IDENT { language=$l.text; } K_BODY body = ((~K_END_BODY)*) { bodyOrClassName = $body.text; } K_END_BODY )
+ | ( K_LANGUAGE l = IDENT { language=$l.text; } K_AS
+ (
+ ( body = STRING_LITERAL
+ { bodyOrClassName = $body.text; }
+ )
+ /* TODO placeholder for pg-style function body */
+ )
+ )
)
{ $expr = new CreateFunctionStatement(bn, fn, language, bodyOrClassName, deterministic, rt, args, orReplace, ifNotExists); }
;
@@ -1236,8 +1243,6 @@ basic_unreserved_keyword returns [String str]
| K_LANGUAGE
| K_NON
| K_DETERMINISTIC
- | K_BODY
- | K_END_BODY
) { $str = $k.text; }
;
@@ -1351,8 +1356,6 @@ K_NON: N O N;
K_OR: O R;
K_REPLACE: R E P L A C E;
K_DETERMINISTIC: D E T E R M I N I S T I C;
-K_END_BODY: E N D '_' B O D Y;
-K_BODY: B O D Y;
// Case-insensitive alpha characters
fragment A: ('a'|'A');