如何在 Hive 中将所有时间戳转换为 EAT table
how to Covert all the timestamps to EST in Hive table
我有一个包含时间戳字段的 Hive table,它可以有任何时区 ..(UTC/PST/CST...)
我想将它们全部转换为一个时间戳 EST。它可以在 Hive 或 Pyspark 中完成。
基本上,我在我的 pyspark 应用程序中使用它,该应用程序在此日期时间字段上具有分组逻辑,在此之前我们希望将 Hive table 中的所有时间转换为 EST 时间。
席德
Sidd,Hive 通常使用写入数据的主机的本地时区。函数 from_utc_timestamp() 和 to_utc_timestamp 对我们很有帮助。在这种情况下,您应该使用 location/region 而不是将时区声明为 UTC/EST,因为这将考虑夏令时。
这里有一个有用的 link 更多示例:Local Time Convert To UTC Time In Hive
如果您还有其他问题,请分享您已经尝试过的方法并分享您的数据示例片段以供进一步调查。
提及 HIV Timezone 对 Y2K38 错误关联的最长时间限制和 JDBC 兼容性问题的事实,
TIMESTAMP type to serde2 that supports unix timestamp (1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC) with optional nanosecond precision using both LazyBinary and LazySimple SerDes.
For LazySimpleSerDe, the data is stored in jdbc compliant java.sql.Timestamp parsable strings.
HIV-2272
Here is simulation associates to supporting timestamps earlier than 1970 and later than 2038.
因此,我认为如果您使用 Date Type 或 String Type 的 HIV DataType 会更好。然后你可以使用任何时区偏移量作为持久性的默认值。
* utc_timestamp is the column name */
/* bellow will convert a timestamp in UTC to EST timezone */
select from_utc_timestamp(utc_timestamp, 'EST') from table1;
希望对您有所帮助。
我有一个包含时间戳字段的 Hive table,它可以有任何时区 ..(UTC/PST/CST...) 我想将它们全部转换为一个时间戳 EST。它可以在 Hive 或 Pyspark 中完成。 基本上,我在我的 pyspark 应用程序中使用它,该应用程序在此日期时间字段上具有分组逻辑,在此之前我们希望将 Hive table 中的所有时间转换为 EST 时间。
席德
Sidd,Hive 通常使用写入数据的主机的本地时区。函数 from_utc_timestamp() 和 to_utc_timestamp 对我们很有帮助。在这种情况下,您应该使用 location/region 而不是将时区声明为 UTC/EST,因为这将考虑夏令时。
这里有一个有用的 link 更多示例:Local Time Convert To UTC Time In Hive
如果您还有其他问题,请分享您已经尝试过的方法并分享您的数据示例片段以供进一步调查。
提及 HIV Timezone 对 Y2K38 错误关联的最长时间限制和 JDBC 兼容性问题的事实,
TIMESTAMP type to serde2 that supports unix timestamp (1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC) with optional nanosecond precision using both LazyBinary and LazySimple SerDes. For LazySimpleSerDe, the data is stored in jdbc compliant java.sql.Timestamp parsable strings. HIV-2272
Here is simulation associates to supporting timestamps earlier than 1970 and later than 2038.
因此,我认为如果您使用 Date Type 或 String Type 的 HIV DataType 会更好。然后你可以使用任何时区偏移量作为持久性的默认值。
* utc_timestamp is the column name */
/* bellow will convert a timestamp in UTC to EST timezone */
select from_utc_timestamp(utc_timestamp, 'EST') from table1;
希望对您有所帮助。