我使用的是flink 1.9版本,在sql中将where条件的一个字段传入了汉字,返回的字段值却是unicode编码。如果不按照汉字做条件,返回的字段值则是汉字。请问有没有人遇到过这个问题?
测试代码:
tEnv.connect(
new Kafka()
.version("universal")
.topic("flink-test-topic-1")
.startFromGroupOffsets()
.property("bootstrap.servers", "192.168.129.101:9192")
.property("group.id", "flink-test-consumer-group")
).withFormat(new Json()
.failOnMissingField(false)
.deriveSchema()
).withSchema(new Schema()
.field("TI", Types.STRING)
.field("EV", Types.STRING)
.field("CS_HOST", Types.STRING)
.field("DCS_ID", Types.STRING)
.field("complex_row",
Types.ROW_NAMED(new String[]{"first_level_row", "first_level_int"},
Types.ROW_NAMED(new String[]{"second_level_str1", "second_level_str2"}, Types.STRING, Types.STRING),
Types.INT))
.field("proc", Types.SQL_TIMESTAMP).proctime()
).inAppendMode().registerTableSource("kafka_src");
Table table1 = tEnv.sqlQuery("select * from kafka_src where TI = '会话登录'");
Table table2 = tEnv.sqlQuery("select * from kafka_src where EV = 'view'");
tEnv.toAppendStream(table1, Row.class).print();
tEnv.toAppendStream(table2, Row.class).print();
输出结果:
\u4F1A\u8BDD\u767B\u5F55,view,-,hCOsDjIKi8pcW0VmFASlY4bTMw7yZG,aaa,bbb,100,2019-09-17T09:42:43.731
会话登录,view,-,hCOsDjIKi8pcW0VmFASlY4bTMw7yZG,aaa,bbb,100,2019-09-17T09:42:43.731
发送自 Windows 10 版邮件<
https://go.microsoft.com/fwlink/?LinkId=550986>应用