sql部分不兼容的地方
时间属性
proctime/event_time类型必须定义为timestamp(3),否则会报错。
在1.11中,ts timestamp,相当于定义timestamp(6)。 而时间属性类型为timestamp(3)
在1.9中,time attr在传递的时候回自动将类型转换为timestamp类型。在1.11中,这不会发生,
传递的类型是LocalDateTime。如果需要,需要你自己定义类型绑定:
/**
* The original table schema may contain generated columns which shouldn't be produced/consumed
* by TableSource/TableSink. And the original TIMESTAMP/DATE/TIME types uses LocalDateTime/LocalDate/LocalTime
* as the conversion classes, however, JDBC connector uses Timestamp/Date/Time classes. So that
* we bridge them to the expected conversion classes.
*
* proc time, event time现在是LocalDateTime类型。
* 事实上大多数数据库系统都不支持。这里的作用是将其绑定到sql的timestamp类型。
*/
def transSqlTypesSchema(schema: TableSchema): TableSchema = {
val physicalSchemaBuilder = TableSchema.builder
schema.getTableColumns.foreach(c => {
if (!c.isGenerated) {
val `type` = DataTypeUtils.transform(c.getType, TypeTransformations.timeToSqlTypes)
physicalSchemaBuilder.field(c.getName, `type`)
}
})
physicalSchemaBuilder.build
}
为了解决这个问题,connector、format、udf可能需要适配LocalDateTime类型。
connector 参数变更。
schema的type通过data-type参数传递,所以connector支持的参数必须添加schema.#.data-type。
在1.11版本中支持通过ddl定义time attr。
定义proctime :
create table test(
ts as proctime()
) with (...)
在source连接器中,必须添加支持:schema.#.expr参数。
定义 event time :
create table test(
user_action_time TIMESTAMP(3)
-- 定义user_action_time为事件时间,最大延迟为5秒钟。
watermark for user_action_time as user_action_time - interval '5' second
) with(..,)
支持这个需要需要支持如下属性:
//connector factory的supportedProperties方法
properties.add("schema.watermark.#.strategy.expr")
properties.add("schema.watermark.#.rowtime")
properties.add("schema.watermark.#.strategy.data-type")
schema获取
schema获取必须通过 TableSchemaUtils.getPhysicalSchema获取,否则会报类型不匹配。
TableSchemaUtils.getPhysicalSchema(desc.getTableSchema(SCHEMA))
filesystem
flink 1.11版本重写了filesystem连接器。
支持分区表,支持json、parquet、orc等格式。
parquet、orc是通过hive的库来支撑的,所以可以压缩。
但是其他格式是通过flink format支持,所以不可以压缩。
filesystem支持通过流来写入文件,如果是未分区表,那么直接写入;如果是分区表,分区需要进行配置才能完成分区提交。

Flink 1.11版本引入了一些重大变化,包括SQL部分的不兼容,如时间属性必须定义为timestamp(3)。文件系统连接器进行了重构,支持分区表和多种格式,新增了Hive Stream功能。此外,还增加了新的DDL语法,如定义主键和分区字段,以及动态表选项。然而,新的Table接口仍有待完善,平台将等待Flink的下一个版本发布新功能。

1万+

被折叠的 条评论
为什么被折叠?



