use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.
the class DefineTableTestCase method test3.
@Test
public void test3() throws SiddhiParserException {
TableDefinition streamDefinition = SiddhiCompiler.parseTableDefinition("define table cseStream ( symbol " + "string, price int, volume float )");
AssertJUnit.assertEquals(TableDefinition.id("cseStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).toString(), streamDefinition.toString());
}
use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.
the class QueryStoreTestCase method test1.
@Test
public void test1() throws SiddhiParserException {
StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "on price>3 " + "select symbol, avg(price) as avgPrice " + "group by symbol " + "having (price >= 20) ;");
AssertJUnit.assertNotNull(query);
StoreQuery api = StoreQuery.query().from(InputStore.store("StockTable").on(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3)))).select(Selector.selector().select(Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("price"))).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20))));
AssertJUnit.assertEquals(api, query);
}
use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.
the class SimpleQueryTestCase method test4.
@Test
public void test4() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from AllStockQuotes#window.lenghtBatch(50) " + "select symbol, avg(price) as avgPrice " + "return ;");
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("AllStockQuotes").window("lenghtBatch", Expression.value(50))).select(Selector.selector().select("symbol", Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("price")))).returns();
AssertJUnit.assertEquals(api, query);
}
use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.
the class SimpleQueryTestCase method test11.
@Test
public void test11() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream[price>3]#window.length(50) " + "select symbol, avg(price) as avgPrice " + "group by symbol " + "having (price >= 20)" + "order by avgPrice " + "limit 5 " + "insert all events into StockQuote; ");
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3))).window("length", Expression.value(50))).select(Selector.selector().select(Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("price"))).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20))).orderBy(Expression.variable("avgPrice")).limit(Expression.value(5))).insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
AssertJUnit.assertEquals(api, query);
}
use of org.wso2.siddhi.query.compiler.exception.SiddhiParserException in project siddhi by wso2.
the class SimpleQueryTestCase method test1.
@Test
public void test1() throws SiddhiParserException {
Query query = SiddhiCompiler.parseQuery("from StockStream[price>3]#window.length(50) " + "select symbol, avg(price) as avgPrice " + "group by symbol " + "having (price >= 20) " + "insert all events into StockQuote; ");
AssertJUnit.assertNotNull(query);
Query api = Query.query().from(InputStream.stream("StockStream").filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3))).window("length", Expression.value(50))).select(Selector.selector().select(Expression.variable("symbol")).select("avgPrice", Expression.function("avg", Expression.variable("price"))).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20)))).insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
AssertJUnit.assertEquals(api, query);
}
Aggregations