Search in sources :

Example 16 with StoreQuery

use of org.wso2.siddhi.query.api.execution.query.StoreQuery in project siddhi by wso2.

the class QueryStoreTestCase method test2.

@Test
public void test2() {
    StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "select symbol, price " + "group by symbol " + "having (7 > price) ;");
    AssertJUnit.assertNotNull(query);
    StoreQuery api = StoreQuery.query().from(InputStore.store("StockTable")).select(Selector.selector().select("symbol", Expression.variable("symbol")).select(Expression.variable("price")).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.value(7), Compare.Operator.GREATER_THAN, Expression.variable("price"))));
    AssertJUnit.assertEquals(api, query);
}
Also used : StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 17 with StoreQuery

use of org.wso2.siddhi.query.api.execution.query.StoreQuery in project siddhi by wso2.

the class QueryStoreTestCase method test4.

@Test
public void test4() {
    StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "on price > 40 " + "within '2017/01/*' " + "per 'day' " + "select symbol, price " + "group by symbol " + "having (7 > price) ;");
    AssertJUnit.assertNotNull(query);
    StoreQuery api = StoreQuery.query().from(InputStore.store("StockTable").on(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(40)), Within.within(Expression.value("2017/01/*")), Expression.value("day"))).select(Selector.selector().select("symbol", Expression.variable("symbol")).select(Expression.variable("price")).groupBy(Expression.variable("symbol")).having(Expression.compare(Expression.value(7), Compare.Operator.GREATER_THAN, Expression.variable("price"))));
    AssertJUnit.assertEquals(api, query);
}
Also used : StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 18 with StoreQuery

use of org.wso2.siddhi.query.api.execution.query.StoreQuery 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);
}
Also used : StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)8 StoreQuery (org.wso2.siddhi.query.api.execution.query.StoreQuery)7 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)4 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)4 Event (org.wso2.siddhi.core.event.Event)3 StoreQueryCreationException (org.wso2.siddhi.core.exception.StoreQueryCreationException)3 FindStoreQueryRuntime (org.wso2.siddhi.core.query.FindStoreQueryRuntime)3 StoreQueryRuntime (org.wso2.siddhi.core.query.StoreQueryRuntime)3 CompiledCondition (org.wso2.siddhi.core.util.collection.operator.CompiledCondition)3 MatchingMetaInfoHolder (org.wso2.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)3 Attribute (org.wso2.siddhi.query.api.definition.Attribute)3 ArrayList (java.util.ArrayList)2 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)2 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)2 Table (org.wso2.siddhi.core.table.Table)2 SiddhiAppContextException (org.wso2.siddhi.query.api.exception.SiddhiAppContextException)2 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 AggregationRuntime (org.wso2.siddhi.core.aggregation.AggregationRuntime)1