use of org.ballerinalang.siddhi.query.api.execution.query.Query in project ballerina by ballerina-lang.
the class TableQueryTestCase method testCreatingDeleteByTypeQuery.
@Test
public void testCreatingDeleteByTypeQuery() {
Query query = Query.query();
query.from(InputStream.stream("cseEventStream").filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value(9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume")))).window("lengthBatch", Expression.value(50)));
query.deleteBy("StockQuote", OutputStream.OutputEventType.ALL_EVENTS, Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote")));
}
use of org.ballerinalang.siddhi.query.api.execution.query.Query in project ballerina by ballerina-lang.
the class TableQueryTestCase method testCreatingInQuery.
@Test
public void testCreatingInQuery() {
Query query = Query.query();
query.from(InputStream.stream("cseEventStream").filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value(9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.in(Expression.compare(Expression.value(9.5), Compare.Operator.GREATER_THAN, Expression.variable("price")), "table"))).window("lengthBatch", Expression.value(50)));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("symbol"))).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.variable("avgPrice"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(50))));
query.insertInto("StockQuote");
}
use of org.ballerinalang.siddhi.query.api.execution.query.Query in project ballerina by ballerina-lang.
the class TableQueryTestCase method testCreatingUpdateByTypeQuery.
@Test
public void testCreatingUpdateByTypeQuery() {
Query query = Query.query();
query.from(InputStream.stream("cseEventStream").filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value(9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume")))).window("lengthBatch", Expression.value(50)));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("volume", Expression.variable("volume")));
query.updateBy("StockQuote", OutputStream.OutputEventType.ALL_EVENTS, UpdateStream.updateSet().set(Expression.variable("price").ofStream("StockQuote"), Expression.variable("price")).set(Expression.variable("volume").ofStream("StockQuote"), Expression.variable("volume")), Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote")));
}
use of org.ballerinalang.siddhi.query.api.execution.query.Query in project ballerina by ballerina-lang.
the class SiddhiCompiler method parseQuery.
public static Query parseQuery(String source) throws SiddhiParserException {
ANTLRInputStream input = new ANTLRInputStream(source);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.query_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (Query) eval.visit(tree);
}
use of org.ballerinalang.siddhi.query.api.execution.query.Query in project ballerina by ballerina-lang.
the class SimpleQueryTestCase method testCreatingReturnFilterQueryWithExtension.
@Test
public void testCreatingReturnFilterQueryWithExtension() {
Query query = Query.query();
query.from(InputStream.stream("StockStream").filter(Expression.and(Expression.compare(Expression.function("ext", "FooBarCond", Expression.value(7), Expression.value(9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.function("ext", "BarCond", Expression.value(100), Expression.variable("volume")))).function("ext", "Foo", Expression.value(67), Expression.value(89)).window("ext", "lengthFirst10", Expression.value(50)));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("avgPrice", Expression.function("ext", "avg", Expression.variable("price"))));
}
Aggregations