zoukankan      html  css  js  c++  java
  • FLink Table API JAVA_BATCH_DEMO

    <dependencies>
    <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-table-api-java-bridge_2.11</artifactId>
    <version>1.9.0</version>
    <!--<scope>provided</scope>-->
    </dependency>
    <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-table-planner_2.11</artifactId>
    <version>1.9.0</version>
    <!--<scope>provided</scope>-->
    </dependency>
    <dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-scala_2.11</artifactId>
    <version>1.9.0</version>
    <!--<scope>provided</scope>-->
    </dependency>

    </dependencies>






    import org.apache.flink.api.java.DataSet;
    import org.apache.flink.api.java.ExecutionEnvironment;
    import org.apache.flink.table.api.Table;
    import org.apache.flink.table.api.java.BatchTableEnvironment;

    /**
    *
    * FLink Java Batch Table API DEMO
    *
    * @author: create by maoxiangyi
    * @version: v1.0
    */
    public class WordCountSql {

    public static void main(String[] args) throws Exception {
    ExecutionEnvironment fbEnv = ExecutionEnvironment.getExecutionEnvironment();
    BatchTableEnvironment fbTableEnv = BatchTableEnvironment.create(fbEnv);

    DataSet<WC> input = fbEnv.fromElements(
    new WC("Hello", 1),
    new WC("Ciao", 1),
    new WC("Hello", 1)
    );


    // register the DataSet as table "WordCount"
    fbTableEnv.registerDataSet("WordCount", input, "word, frequency");

    // run a SQL query on the Table and retrieve the result as a new Table
    Table table = fbTableEnv.sqlQuery(
    "SELECT word, SUM(frequency) as frequency FROM WordCount GROUP BY word");

    DataSet<com.xesv5.mxy.WC> result = fbTableEnv.toDataSet(table, com.xesv5.mxy.WC.class);

    result.print();
    }
    }










  • 相关阅读:
    cf1108E2 线段树类似扫描线
    poj1185 状态压缩经典题
    cf1110F 离线+树上操作+线段树区间更新
    tarjan求lca :并查集+dfs
    cf1110E 思维
    cf1110d 线性dp
    cf842D 01字典树|线段树 模板见hdu4825
    cf842C 树形dp+gcd函数
    cf581F 依赖背包+临时数组 好题
    hdu5758 思维,树形dp
  • 原文地址:https://www.cnblogs.com/maoxiangyi/p/11869190.html
Copyright © 2011-2022 走看看