mybatis-plus 查询hive数据库报错Required field ‘type‘ is unset
org.apache.thrift.protocol.TProtocolException: Required field 'type' is unset! Struct:TPrimitiveTypeEntry(type:null
·
mybatis-plus 查询hive数据库,报错Required field 'type' is unset!
报错org.apache.thrift.protocol.TProtocolException: Required field ‘type’ is unset! Struct:TPrimitiveTypeEntry(type:null, typeQualifiers:TTypeQualifiers(qualifiers:{characterMaximumLength=}))
可能的原因之一
hive数据库中有两种存储字符的类型,varchar 和 string。
如果hive 数据库字段里是varchar类型,在java类中用String接收,就会报错:org.apache.thrift.protocol.TProtocolException: Required field ‘type’ is unset!
这里的hive版本为:
使用DBeaver连接hive数据库,看表字段类型如下;
Mapper.java
报错:
解决办法:
类型转换 使用 cast 函数将 varchar 转成 string
然后就查询成功了。

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)