好的,所以我可能有点重载了标题,但我们正在使用sqoop 1.4.6.2.5.3.0-37(hdp 2.5.3(提取数据。
当 sqoop 执行其导入时间戳字段时,将以毫秒纪元的形式出现。
Postgres schema
Column | Type | Modifiers
------------------+--------------------------+------------------------------------------------------------
id | integer | not null default nextval('foo'::regclass)
x | integer |
y | integer |
z | character varying(255) |
created_at | timestamp with time zone |
updated_at | timestamp with time zone |
配置单元架构
id int
x int
y int
z string
created_at bigint
updated_at bigint
如何让 sqoop 导入将时间戳字段视为镶木地板/avro 中的原生日期?
数据被配置为外部表,因此我们可以直接使用 java/spark 之类的东西来访问它。我已经尝试了几种不同的字段映射(java(,但到目前为止,实际上没有任何内容保留该类型
> Sqoop为这个Postgres表创建了一个POJO类。它正在将created_at
和updated_at
转换为Types.BIGINT
。
这就是在 Hive 中获取其相应BIGINT
数据类型的原因。
在配置单元中,时间戳被解释为无时区。如果您尝试在 hive 的时间戳值中插入2016-02-23 14:00:21.426484-05
,它将为此插入NULL
。
您所能做的就是将这些列转换为VARCHAR
或STRING
尝试添加 Java 映射
--map-column-java created_at=String, updated_at=String
和配置单元映射
--map-column-hive created_at=string, updated_at=string
或
--map-column-hive created_at='varchar(50)', updated_at='varchar(50)'
对于sqoop的默认java和hive映射检查:sqoop如何将sql数据类型转换为hive。