开发者社区> 问答> 正文

flinksql写hive的时候,数据类型不匹配怎么办?

Flink SQL> insert into upd_sh.dr1 select cast('cid' as string) as cid, cast(2001 as bigint) as server_time, cast('20211027' as string) as dt, cast('01' as str ing) as hour, cast('7102' as string) as supply_id, cast(map['sid','7102', 'subid', 'i am a subid'] as map<string,string>) as d; [INFO] Submitting SQL update statement to the cluster... [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Column types of query result and sink for registered table 'hive.upd_sh.dr1' do not match. Cause: Incompatible types for sink column 'd' at position 2.

Query schema: [cid: STRING NOT NULL, server_time: BIGINT NOT NULL, dt: STRING NOT NULL, hour: STRING NOT NULL, supply_id: STRING NOT NULL, d: MAP<STRING, STRING> NOT NULL] Sink schema: [cid: STRING, server_time: BIGINT, d: MAP<STRING, STRING>, dt: STRING, hour: STRING, supply_id: STRING]*来自志愿者整理的flink邮件归档

展开
收起
彗星halation 2021-12-02 17:20:59 1764 0
1 条回答
写回答
取消 提交回答
  • 是字段的顺序不一致(sink schema 里 d 在第三个,query 里 d 在最后)。需要将这两个顺序调整到一致。*来自志愿者整理的FLINK邮件归档

    2021-12-02 17:43:34
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Hive Bucketing in Apache Spark 立即下载
spark替代HIVE实现ETL作业 立即下载
2019大数据技术公开课第五季—Hive迁移到MaxCompute最佳实践 立即下载