use of org.wso2.siddhi.query.api.execution.query.input.handler.Window in project siddhi by wso2.
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.wso2.siddhi.query.api.execution.query.input.handler.Window in project siddhi by wso2.
the class TableQueryTestCase method testCreatingDeleteQuery.
@Test
public void testCreatingDeleteQuery() {
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", Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote")));
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Window in project siddhi by wso2.
the class SiddhiApp method defineWindow.
public SiddhiApp defineWindow(WindowDefinition windowDefinition) {
if (windowDefinition == null) {
throw new SiddhiAppValidationException("Window Definition should not be null");
} else if (windowDefinition.getId() == null) {
throw new SiddhiAppValidationException("Window Id should not be null for Window Definition", windowDefinition.getQueryContextStartIndex(), windowDefinition.getQueryContextEndIndex());
}
checkDuplicateDefinition(windowDefinition);
this.windowDefinitionMap.put(windowDefinition.getId(), windowDefinition);
return this;
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Window in project siddhi by wso2.
the class SimpleQueryTestCase method testCreatingReturnFilterQuery.
// from StockStream[win.lengthBatch(50)][price >= 20]
// return symbol, avg(price) as avgPrice
@Test
public void testCreatingReturnFilterQuery() {
Query query = Query.query();
query.from(InputStream.stream("StockStream").filter(Expression.and(Expression.compare(Expression.divide(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("avgPrice", Expression.function("avg", Expression.variable("price"))));
query.returns();
}
use of org.wso2.siddhi.query.api.execution.query.input.handler.Window in project siddhi by wso2.
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