Search in sources :

Example 1 with KsqlContext

use of io.confluent.ksql.KsqlContext in project ksql by confluentinc.

the class EmbeddedKsql method main.

public static void main(String[] args) throws Exception {
    KsqlContext ksqlContext = KsqlContext.create(new KsqlConfig(Collections.emptyMap()));
    ksqlContext.sql("REGISTER TOPIC orders_topic WITH (format = 'json', " + "kafka_topic='orders_topic_json');");
    ksqlContext.sql("CREATE STREAM orders (ordertime bigint, orderid bigint, itemid varchar, " + "orderunits double, arraycol array<double>, mapcol map<varchar, double>) " + "WITH (topicname = 'orders_topic' , key='orderid');\n");
    ksqlContext.sql("CREATE STREAM BIGORDERS AS SELECT * FROM ORDERS WHERE ORDERUNITS > 5;");
    ksqlContext.sql("SELECT * FROM ORDERS;");
    ksqlContext.sql("CREATE TABLE ORDERSUMS AS select itemid, sum(orderunits) from orders window " + "TUMBLING ( size 30 second) group by itemid;");
    System.out.println("Queries are running!");
}
Also used : KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlContext(io.confluent.ksql.KsqlContext)

Aggregations

KsqlContext (io.confluent.ksql.KsqlContext)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1