简体   繁体   English

使用sqoop导入到hdfs时,如何在Postgres中更改列的类型?

[英]How can I change type of a column in Postgres while using sqoop import to hdfs?

I have a column in Postgres database with a type timestamp without timezone. 我在Postgres数据库中有一列,其时间戳类型没有时区。 How do I convert it into timestamp with timezone(UTC) while importing into hdfs using sqoop? 如何在使用sqoop导入hdfs时将其转换为带有时区(UTC)的时间戳?

You can specify the query rather than table in your sqoop import statement. 您可以在sqoop import语句中指定查询而不是表。

 sqoop import --connect xxx,DATABASE=xxx
 ---driver xxx --username xxx --password xxx 
 --query 'select * from xxx' 
 --target-dir <hdfs-location> ...

Here is how you can convert from timestamp without timezone to timezone(UTC) 这是从无时区的时间戳转换为时区(UTC)的方法

SELECT '2011-01-01 00:00:00'::TIMESTAMP WITH TIME ZONE;

You can refer this link : Difference between timestamps with/without time zone in PostgreSQL 您可以参考以下链接: PostgreSQL中带/不带时区的时间戳之间的差异

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM