使用Flink connector读取sr 日期类型数据不正确

【详述】采用flink connector读取表中的的日期类型数据不正确
【业务影响】
【StarRocks版本】例如:2.2.2
【集群规模】例如:3fe(3follower)+3be(fe与be混部)
【机器信息】CPU虚拟核/内存/网卡,例如:40C/128G/千兆
【附件】
sr表数据如下:
image
建表部分列如下:
image
核心代码如下:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StarRocksSourceOptions options = StarRocksSourceOptions.builder()
.withProperty(“scan-url”, “xxxxx:8030,xxx:8030,xxx:8030”)
.withProperty(“jdbc-url”, “jdbc:mysql://xxxxx:9030”)
.withProperty(“username”, “data”)
.withProperty(“password”, “123”)
.withProperty(“table-name”, “dm_skincare_makeup”)
.withProperty(“database-name”, “dm”)
.build();
TableSchema tableSchema = TableSchema.builder()
.field(“month”, DataTypes.DATE())
.field(“platform_id”, DataTypes.INT())

.build();
env.addSource(StarRocksSource.source(tableSchema, options)).print();
打印结果:
image
上述日期显示不正确。

可能是跟字段是关键字(month)有关,麻烦您测试下.field(“month”, DataTypes.DATE()) 把这里的字段类型改为string试一下,或者对该字段做个转义

1.改成string
.field(“month”, DataTypes.STRING())
类型转换报错:
Caused by: java.lang.RuntimeException: StarRocks type can not convert to flink type, starrocks type is -> [DATE] flink type is -> [VARCHAR]
2.加转义符
image
找不到字段名:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Can not find StarRocks column data column name is -> [month]

什么时候修复一下这个问题呢

应该跟关键字(month)没有关系,我表里还有一个字段,名称是access_date,也是这种情况。

@dongquan @yuchen1019 @zhaoheng 请问这个是一个bug吗?

通过查看flink RowData类源码发现:


date类型出来的值是从1970-01-01到现在的天数,所以需要转换一下才行。