Search in sources :

Example 6 with StoreQuery

use of org.ballerinalang.siddhi.query.api.execution.query.StoreQuery in project ballerina by ballerina-lang.

the class QueryStoreTestCase method test3.

@Test
public void test3() {
    StoreQuery query = SiddhiCompiler.parseStoreQuery("" + "from StockTable " + "on price > 40 " + "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)))).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.ballerinalang.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 7 with StoreQuery

use of org.ballerinalang.siddhi.query.api.execution.query.StoreQuery in project ballerina by ballerina-lang.

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.ballerinalang.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Aggregations

StoreQuery (org.ballerinalang.siddhi.query.api.execution.query.StoreQuery)7 Test (org.testng.annotations.Test)4 ArrayList (java.util.ArrayList)1 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 ComplexEventChunk (org.ballerinalang.siddhi.core.event.ComplexEventChunk)1 Event (org.ballerinalang.siddhi.core.event.Event)1 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)1 StreamEvent (org.ballerinalang.siddhi.core.event.stream.StreamEvent)1 StoreQueryRuntime (org.ballerinalang.siddhi.core.query.StoreQueryRuntime)1 Table (org.ballerinalang.siddhi.core.table.Table)1 TimePeriod (org.ballerinalang.siddhi.query.api.aggregation.TimePeriod)1 BasicSelector (org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector)1 Selector (org.ballerinalang.siddhi.query.api.execution.query.selection.Selector)1 SiddhiQLBaseVisitorImpl (org.ballerinalang.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl)1