use of io.siddhi.query.api.definition.TableDefinition in project siddhi by wso2.
the class SiddhiCompiler method parseTableDefinition.
public static TableDefinition parseTableDefinition(String tableDefinition) throws SiddhiParserException {
CharStream input = CharStreams.fromString(tableDefinition);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.definition_table_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (TableDefinition) eval.visit(tree);
}
use of io.siddhi.query.api.definition.TableDefinition in project siddhi by wso2.
the class DefineTableTestCase method test1.
@Test
public void test1() 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 io.siddhi.query.api.definition.TableDefinition in project siddhi by wso2.
the class DefineTableTestCase method test4.
@Test
public void test4() throws SiddhiParserException {
TableDefinition streamDefinition = SiddhiCompiler.parseTableDefinition("" + " @from(datasource='MyDatabase','CUSTOM')" + " 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).annotation(Annotation.annotation("from").element("datasource", "MyDatabase").element("CUSTOM")).toString(), streamDefinition.toString());
}
use of io.siddhi.query.api.definition.TableDefinition 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 io.siddhi.query.api.definition.TableDefinition in project siddhi by wso2.
the class DefineTableTestCase method testQuery1.
@Test
public void testQuery1() throws InterruptedException {
log.info("testTableDefinition1 - OUT 0");
SiddhiManager siddhiManager = new SiddhiManager();
TableDefinition tableDefinition = TableDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT);
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineTable(tableDefinition);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
}
Aggregations