大时间表 vs Table 时间表

Flink Schema vs Table Schema

我正在使用 Flink SQL API,我在所有 'schema' 类型之间有点迷茫:TableSchemaSchema(来自 org.apache.flink.table.descriptors.Schema) 和 TypeInformation.

TableSchema 可以从 TypeInformation 创建,TypeInformation 可以从 TableSchema 创建,Schema 可以从 TypeInformation 创建TableSchema

但看起来 Schema 无法转换回 TypeInformationTableSchema (?)

为什么有3种不同类型的对象来存储同一种信息?

例如,假设我有一个来自 Avro 模式文件的字符串模式,我想向它添加一个新字段。为此,我找到的唯一解决方案是:

String mySchemaRaw = ...;
TypeInformation<Row> typeInfo = AvroSchemaConverter.convertToTypeInfo(mySchemaRaw);
Schema newSchema = new Schema().schema(TableSchema.fromTypeInfo(typeInfo));
newSchema = newSchema.field("nexField",...);


// Need the newSchema as a TableSchema 

这是使用这些对象的正常方式吗? (我觉得很奇怪)

TypeInformationTableSchema 解决不同的事情。 TypeInformation 是如何将记录 class(例如一行或 POJO)从一个运算符传送到另一个运算符的物理信息。

TableSchema 描述了 table 的架构,独立于底层的每条记录类型。它类似于 CREATE TABLE name (a INT, b BIGINT) DDL 语句的模式部分。在 SQL 中也没有像 CREATE TABLE name ROW(a INT, B BIGINT) 那样定义 table。但模式和行类型确实相关,这就是提供转换器方法的原因。一旦引入 PRIMARY KEY 等概念,差异就会变得更大。

Schema 是当前指定非 SQL 概念(例如时间属性和字段映射)的方式。