我尝试像这样创建表格:
Flink SQL> create table test (nested ROW(id STRING, name STRING)) partitioned by (nested.id);
但我收到此错误:
[ERROR] Could not execute SQL statement. Reason:
org.apache.flink.sql.parser.impl.ParseException: Encountered "." at line 1, column 78.
Was expecting one of:
")" ...
"," ...
我尝试了很多选项:
partitioned by ('nested.id')
,partitioned by (nested.id)
,但它们都失败了。文档中也没有提到这一点。
几乎没有这方面的文档,但我想通了:
Schema schema = new Schema(
optional(1, "id", Types.IntegerType.get()),
optional(2, "name", Types.StringType.get()),
optional(3, "address", Types.StructType.of(
optional(4, "street", Types.StringType.get()),
optional(5, "city", Types.StringType.get()),
optional(6, "state", Types.StringType.get()),
optional(7, "zip", Types.IntegerType.get())
))
);
Table table = new TableBuilder()
.withSchema(schema)
.withPartitionSpec(PartitionSpec.builderFor(schema)
.identity("id")
.bucket("address.city", 16)
.build())
.build();