diff --git a/cql3/Cql.g b/cql3/Cql.g index b5a9de5f73..2922ab21cb 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -38,6 +38,7 @@ options { #include "cql3/statements/update_statement.hh" #include "cql3/statements/delete_statement.hh" #include "cql3/statements/use_statement.hh" +#include "cql3/statements/batch_statement.hh" #include "cql3/statements/ks_prop_defs.hh" #include "cql3/selection/raw_selector.hh" #include "cql3/constants.hh" @@ -223,9 +224,7 @@ cqlStatement returns [shared_ptr stmt] : st1= selectStatement { $stmt = st1; } | st2= insertStatement { $stmt = st2; } | st3= updateStatement { $stmt = st3; } -#if 0 | st4= batchStatement { $stmt = st4; } -#endif | st5= deleteStatement { $stmt = st5; } | st6= useStatement { $stmt = st6; } #if 0 @@ -464,7 +463,6 @@ usingClauseDelete[::shared_ptr attrs] : K_USING K_TIMESTAMP ts=intValue { attrs->timestamp = ts; } ; -#if 0 /** * BEGIN BATCH * UPDATE SET name1 = value1 WHERE KEY = keyname1; @@ -489,28 +487,30 @@ usingClauseDelete[::shared_ptr attrs] * ... * APPLY BATCH */ -batchStatement returns [BatchStatement.Parsed expr] +batchStatement returns [shared_ptr expr] @init { - BatchStatement.Type type = BatchStatement.Type.LOGGED; - List statements = new ArrayList(); - Attributes.Raw attrs = new Attributes.Raw(); + using btype = cql3::statements::batch_statement::type; + btype type = btype::LOGGED; + std::vector> statements; + auto attrs = make_shared(); } : K_BEGIN - ( K_UNLOGGED { type = BatchStatement.Type.UNLOGGED; } | K_COUNTER { type = BatchStatement.Type.COUNTER; } )? + ( K_UNLOGGED { type = btype::UNLOGGED; } | K_COUNTER { type = btype::COUNTER; } )? K_BATCH ( usingClause[attrs] )? - ( s=batchStatementObjective ';'? { statements.add(s); } )* + ( s=batchStatementObjective ';'? { statements.push_back(std::move(s)); } )* K_APPLY K_BATCH { - return new BatchStatement.Parsed(type, attrs, statements); + $expr = ::make_shared(type, std::move(attrs), std::move(statements)); } ; -batchStatementObjective returns [ModificationStatement.Parsed statement] +batchStatementObjective returns [shared_ptr statement] : i=insertStatement { $statement = i; } | u=updateStatement { $statement = u; } | d=deleteStatement { $statement = d; } ; +#if 0 createAggregateStatement returns [CreateAggregateStatement expr] @init { boolean orReplace = false;