@PublicEvolving public interface GroupedTable
Modifier and Type | Method and Description |
---|---|
AggregatedTable |
aggregate(Expression aggregateFunction)
Performs an aggregate operation with an aggregate function.
|
FlatAggregateTable |
flatAggregate(Expression tableAggFunction)
Performs a flatAggregate operation on a grouped table.
|
Table |
select(Expression... fields)
Performs a selection operation on a grouped table.
|
Table select(Expression... fields)
Example:
tab.groupBy($("key")).select($("key"), $("value").avg().plus(" The average").as("average"));
Scala Example:
tab.groupBy($"key").select($"key", $"value".avg + " The average" as "average")
AggregatedTable aggregate(Expression aggregateFunction)
aggregate(Expression)
with a select statement. The output will be flattened if the output
type is a composite type.
Example:
tableEnv.createTemporarySystemFunction("aggFunc", MyAggregateFunction.class);
tab.groupBy($("key"))
.aggregate(call("aggFunc", $("a"), $("b")).as("f0", "f1", "f2"))
.select($("key"), $("f0"), $("f1"));
Scala Example:
val aggFunc = new MyAggregateFunction
table.groupBy($"key")
.aggregate(aggFunc($"a", $"b") as ("f0", "f1", "f2"))
.select($"key", $"f0", $"f1")
FlatAggregateTable flatAggregate(Expression tableAggFunction)
Example:
tableEnv.createTemporarySystemFunction("tableAggFunc", MyTableAggregateFunction.class);
tab.groupBy($("key"))
.flatAggregate(call("tableAggFunc", $("a"), $("b")).as("x", "y", "z"))
.select($("key"), $("x"), $("y"), $("z"));
Scala Example:
val tableAggFunc: TableAggregateFunction = new MyTableAggregateFunction
tab.groupBy($"key")
.flatAggregate(tableAggFunc($"a", $"b") as ("x", "y", "z"))
.select($"key", $"x", $"y", $"z")
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.