[DataX]DataX向hive同步数据时Date类型和TimeStamp类型显示ORC does not support type conversion from file type struct<> (2) to reader type date (2)

出现问题

DataX向hive同步数据时Date类型和TimeStamp类型显示ORC does not support type conversion from file type struct<> (2) to reader type date (2)

问题来源

DataX向hive中写入数据时,Date数据类型和TimeStamp数据类型使用java.sql.Timestamp.class和java.sql.Date.class

解决方法

将java.sql.Timestamp.class和java.sql.Date.class类型修改为org.apache.hadoop.hive.common.type.Timestamp.classorg.apache.hadoop.hive.common.type.Date.class类型

在/DataX/hdfswriter/src/main/java/com/alibaba/datax/plugin/writer/hdfswriter/HdfsHelper.java文件的getColumnTypeInspectors()方法中修改

                case TIMESTAMP:
                    objectInspector = //ObjectInspectorFactory.getReflectionObjectInspector(java.sql.Timestamp.class, ObjectInspectorFactory.ObjectInspectorOptions.JAVA);
ObjectInspectorFactory.getReflectionObjectInspector(org.apache.hadoop.hive.common.type.Timestamp.class,ObjectInspectorFactory.ObjectInspectorOptions.JAVA)
                    break;
                case DATE:
                    objectInspector = ObjectInspectorFactory.getReflectionObjectInspector(org.apache.hadoop.hive.common.type.Date.class, ObjectInspectorFactory.ObjectInspectorOptions.JAVA);
                    break;

在/DataX/hdfswriter/src/main/java/com/alibaba/datax/plugin/writer/hdfswriter/HdfsHelper.java文件的transportOneRecord()方法中修改

case DATE:
// recordList.add(new java.sql.Date(column.asDate().getTime()));
recordList.add(org.apache.hadoop.hive.common.type.Date.ofEpochMilli(column.asDate().getTime()));
break;
case TIMESTAMP:
// recordList.add(new java.sql.Timestamp(column.asDate().getTime()));
recordList.add(org.apache.hadoop.hive.common.type.Timestamp.ofEpochMilli(column.asDate().getTime()));
break;

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇
Theme Argon
本网站自 2020-12-24 12:00:00 起已运行