flink版本1.7.2
flink table api从kafka读取json数据,JsonSchema如下图所示
发现rowtime无法从子json中的字段指定,麻烦帮忙确认下rowtime是否只能从顶层的字段来指定?
tableEnv.connect(
new Kafka()
.version("0.10")
.topic(topic_in)
.property("bootstrap.servers", brokers)
.property("group.id", "TableApiT2")
.startFromLatest()
).withFormat(
new Json()
.jsonSchema(
"""
|{
| "type": 'object',
| "properties": {
| "metric": {
| "type": 'object',
| "properties": {
| "time_stamp": {
| "type": 'string',
| format: 'date-time'
| },
| "event_time": {
| "type": 'string'
| },
| "cluster": {
| "type": 'string'
| },
| "host": {
| "type": 'string'
| },
| "instance": {
| "type": 'string'
| },
| "index_name": {
| "type": 'string'
| },
| "index_num": {
| "type": 'string'
| },
| "value": {
| "type": 'number'
| }
| }
| },
| "source": {
| "type": 'string'
| }
| }
|}
|""".stripMargin
)
).withSchema(
new Schema()
.field("metric",
Types.ROW_NAMED(
Array("time_stamp", "event_time", "cluster", "host", "instance",
"index_name", "index_num", "value"),
Types.SQL_TIMESTAMP,
Types.STRING,
Types.STRING,
Types.STRING,
Types.STRING,
Types.STRING,
Types.STRING,
Types.BIG_DEC
)
) //***如何指定上面row类型中time_stamp为rowtime
).inAppendMode()
.registerTableSource("metricTable")