You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2017/09/26 11:55:54 UTC
flink git commit: [hotfix] [docs] Simplify and fix Table UDF docs
Repository: flink
Updated Branches:
refs/heads/master d3458ec7b -> 2d393e882
[hotfix] [docs] Simplify and fix Table UDF docs
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/2d393e88
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/2d393e88
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/2d393e88
Branch: refs/heads/master
Commit: 2d393e882fd99fa6bcd5df19ff1aa345909c145c
Parents: d3458ec
Author: twalthr <tw...@apache.org>
Authored: Tue Sep 26 13:54:23 2017 +0200
Committer: twalthr <tw...@apache.org>
Committed: Tue Sep 26 13:55:21 2017 +0200
----------------------------------------------------------------------
docs/dev/table/udfs.md | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/2d393e88/docs/dev/table/udfs.md
----------------------------------------------------------------------
diff --git a/docs/dev/table/udfs.md b/docs/dev/table/udfs.md
index 16f21e9..71567d8 100644
--- a/docs/dev/table/udfs.md
+++ b/docs/dev/table/udfs.md
@@ -235,8 +235,7 @@ public class CustomTypeSplit extends TableFunction<Row> {
@Override
public TypeInformation<Row> getResultType() {
- return new RowTypeInfo(new TypeInformation[]{
- BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO});
+ return Types.ROW(Types.STRING(), Types.INT());
}
}
{% endhighlight %}
@@ -255,8 +254,7 @@ class CustomTypeSplit extends TableFunction[Row] {
}
override def getResultType: TypeInformation[Row] = {
- new RowTypeInfo(Seq(BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO))
+ Types.ROW(Types.STRING, Types.INT)
}
}
{% endhighlight %}
@@ -526,7 +524,7 @@ public static class WeightedAvgAccum {
/**
* Weighted Average user-defined aggregate function.
*/
-public static class WeightedAvg extends AggregateFunction<long, WeightedAvgAccum> {
+public static class WeightedAvg extends AggregateFunction<Long, WeightedAvgAccum> {
@Override
public WeightedAvgAccum createAccumulator() {
@@ -534,7 +532,7 @@ public static class WeightedAvg extends AggregateFunction<long, WeightedAvgAccum
}
@Override
- public long getValue(WeightedAvgAccum acc) {
+ public Long getValue(WeightedAvgAccum acc) {
if (acc.count == 0) {
return null;
} else {
@@ -581,8 +579,8 @@ tEnv.sqlQuery("SELECT user, wAvg(points, level) AS avgPoints FROM userScores GRO
{% highlight scala %}
import java.lang.{Long => JLong, Integer => JInteger}
import org.apache.flink.api.java.tuple.{Tuple1 => JTuple1}
-import org.apache.flink.api.common.typeinfo.{BasicTypeInfo, TypeInformation}
import org.apache.flink.api.java.typeutils.TupleTypeInfo
+import org.apache.flink.table.api.Types
import org.apache.flink.table.functions.AggregateFunction
/**
@@ -635,13 +633,10 @@ class WeightedAvg extends AggregateFunction[JLong, CountAccumulator] {
}
override def getAccumulatorType: TypeInformation[WeightedAvgAccum] = {
- new TupleTypeInfo(classOf[WeightedAvgAccum],
- BasicTypeInfo.LONG_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO)
+ new TupleTypeInfo(classOf[WeightedAvgAccum], Types.LONG, Types.INT)
}
- override def getResultType: TypeInformation[JLong] =
- BasicTypeInfo.LONG_TYPE_INFO
+ override def getResultType: TypeInformation[JLong] = Types.LONG
}
// register function