FlinkSql(二)API使用-transform

这个算子可以说是很多的,查看官方文档即可https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/tableApi.html#column-operations

这个是从flink官网整下来的,需要什么找那个就行

// environment configuration
// ...

// specify table program
val orders: Table = tEnv.from("Orders") // schema (a, b, c, rowtime)

val result: Table = orders
        .filter($"a".isNotNull && $"b".isNotNull && $"c".isNotNull)
        .select($"a".lowerCase() as "a", $"b", $"rowtime")
        .window(Tumble over 1.hour on $"rowtime" as "hourlyWindow")
        .groupBy($"hourlyWindow", $"a")
        .select($"a", $"hourlyWindow".end as "hour", $"b".avg as "avgBillingAmount")
    val resultTable: Table = sensorTable
    //在调用方法时字段更加推荐'ziduan的方式进行编写
      .select('id, 'temp)
      .filter('id === "sensor_1")
    // 4.2 聚合转换(聚合我们的习惯是groupBy写在后边,但是编写代码先分组后查询)
    val aggResultTable: Table = sensorTable
      .groupBy('id)
      .select('id, 'id.count as 'count)

猜你喜欢

转载自blog.csdn.net/weixin_43233971/article/details/107887833
今日推荐