Java Code Examples for io.siddhi.query.api.execution.query.Query#insertIntoFault()

The following examples show how to use io.siddhi.query.api.execution.query.Query#insertIntoFault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuery6() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    filter(
                            Expression.isNullFaultStream("StockStream")
                    )
    );
    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.insertIntoFault("OutStockStream");

    SiddhiApp.siddhiApp("test").addQuery(query);
}
 
Example 2
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuery7() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    filter(
                            Expression.isNullFaultStream("StockStream", 1)
                    )
    );
    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.insertIntoFault("OutStockStream");

    SiddhiApp.siddhiApp("test").addQuery(query);
}
 
Example 3
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuery8() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    filter(
                            Expression.isNullInnerStream("StockStream", 1)
                    )
    );
    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.insertIntoFault("OutStockStream");

    SiddhiApp.siddhiApp("test").addQuery(query);
}
 
Example 4
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuery9() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    filter(
                            Expression.isNullInnerStream("StockStream")
                    )
    );
    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.insertIntoFault("OutStockStream");

    SiddhiApp.siddhiApp("test").addQuery(query);
}
 
Example 5
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatingFilterQueryWithFaultStream() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    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")
                                    )
                            )
                    )
    );
    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.insertIntoFault("OutStockStream");

    SiddhiApp.siddhiApp("test").addQuery(query);

}
 
Example 6
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatingFilterQueryWithFaultStream2() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("e1", "StockStream").
                    filter(
                            Expression.and(
                                    Expression.compare(
                                            Expression.add(Expression.value(7), Expression.value(9.5)),
                                            Compare.Operator.GREATER_THAN,
                                            Expression.variable("price").ofStream("e1")),
                                    Expression.compare(
                                            Expression.value(100),
                                            Compare.Operator.GREATER_THAN_EQUAL,
                                            Expression.variable("volume").ofStream("e1")
                                    )
                            )
                    )
    );
    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.insertIntoFault("OutStockStream");
    SiddhiApp.siddhiApp("test").addQuery(query);
}
 
Example 7
Source File: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreatingFilterQueryWithFaultStream3() {
    Query query = Query.query();
    query.from(
            InputStream.faultStream("StockStream").
                    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")
                                    )
                            )
                    )
    );
    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.insertIntoFault("OutStockStream", OutputStream.OutputEventType.CURRENT_EVENTS);
    SiddhiApp.siddhiApp("test").addQuery(query);
}