Search in sources :

Example 1 with StoreQuery

use of io.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);
    OnDemandQuery api = OnDemandQuery.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(io.siddhi.query.api.execution.query.StoreQuery) OnDemandQuery(io.siddhi.query.api.execution.query.OnDemandQuery) Test(org.testng.annotations.Test)

Example 2 with StoreQuery

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

the class OnDemandQueryTestCase method test6.

@Test
public void test6() {
    StoreQuery storeQuery = StoreQuery.query();
    storeQuery.from(InputStore.store("StockTable")).select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price"))).updateBy("StockTable", UpdateStream.updateSet().set(Expression.variable("symbol").ofStream("StockStream"), Expression.variable("symbol")).set(Expression.variable("price").ofStream("StockStream"), Expression.variable("price")), Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol")));
}
Also used : StoreQuery(io.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 3 with StoreQuery

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

the class OnDemandQueryTestCase method test4.

@Test
public void test4() {
    StoreQuery storeQuery = StoreQuery.query();
    storeQuery.from(InputStore.store("StockTable")).select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price"))).updateBy("StockTable", Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol")));
    AssertJUnit.assertNotNull(storeQuery.toString());
}
Also used : StoreQuery(io.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 4 with StoreQuery

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

the class OnDemandQueryTestCase method test5.

@Test
public void test5() {
    StoreQuery storeQuery = StoreQuery.query();
    storeQuery.from(InputStore.store("StockTable")).select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price"))).deleteBy("StockTable", Expression.compare(Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol")));
}
Also used : StoreQuery(io.siddhi.query.api.execution.query.StoreQuery) Test(org.testng.annotations.Test)

Example 5 with StoreQuery

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

Aggregations

StoreQuery (io.siddhi.query.api.execution.query.StoreQuery)6 Test (org.testng.annotations.Test)6 OnDemandQuery (io.siddhi.query.api.execution.query.OnDemandQuery)2