[英]Error while creating a tumbling window in Apache Flink Java
我尝试在 Flink Java 中创建 2 行的翻滚时间 window。 这必须基于 dateTime(TimeStamp3 数据类型)或 unixDateTime(BIGINT 数据类型)列。 我添加了两个不同代码版本的代码。 我得到的错误放在代码上方。
当我打印Table
object 的数据类型时,我看到: |-- mID: INT |-- dateTime: TIMESTAMP(3) *ROWTIME* |-- mValue: DOUBLE |-- unixDateTime: BIGINT |-- mType: STRING
StreamExecutionEnvironment fsEnv = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(fsEnv);
fsEnv.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
TupleTypeInfo<Tuple5<Integer, Timestamp, Double, Long, String>> tupleType = new TupleTypeInfo<>(
Types.INT(),
Types.SQL_TIMESTAMP(),
Types.DOUBLE(),
Types.LONG(),
Types.STRING());
DataStream<Tuple5<Integer, Timestamp, Double, Long, String>> dsTuple =
tableEnv.toAppendStream(HTable, tupleType);
//When I run below code I get this error: Caused by: java.lang.RuntimeException: Rowtime timestamp is null. Please make sure that a proper TimestampAssigner is defined and the stream environment uses the EventTime time characteristic.
Table table = tableEnv.fromDataStream(dsTuple, "mID, dateTime.rowtime, mValue, unixDateTime, mType");
DataStream<Row> stream = tableEnv.toAppendStream(table, Row.class);
stream.print();
//When I run below code I get this error: Exception in thread "main" java.lang.UnsupportedOperationException: Event-time grouping windows on row intervals are currently not supported.
Table table = tableEnv.fromDataStream(dsTuple, "mID, dateTime.rowtime, measurementValue, unixDateTime, measurementType")
.window(Tumble.over("2.rows")
.on("dateTime")
.as("a"))
.groupBy("a")
.select("AVG(mValue)");
DataStream<Row> stream = tableEnv.toAppendStream(table, Row.class);
stream.print();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.