unix\u timestamp对于配置单元的行为不正确

weylhg0b  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(374)

在单个hql中,我有以下两个insert查询,其中我将表“final\u table\u temp”中的几个字段插入final\u table1和final\u table2。两个目标表具有完全相同的结构。

insert into Final_table1
PARTITION(event_date,service_id)
select from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd HH:00:00.0'),
from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd') as event_date,
service_id 
from Final_table_temp;

insert into Final_table2
PARTITION(event_date,service_id)
select from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd HH:00:00.0'),
from_unixtime(unix_timestamp(event_timestamp ,'yyyy-MM-dd HH'), 'yyyy-MM-dd') as event_date,
service_id 
from Final_table_temp;

最终\u表\u temp中的事件\u时间戳值:

2017-10-26 22

最终\u表1中的事件\u时间戳值:

2017-10-26 22:00:00.000

最终\u表2中的事件\u时间戳值:

2017-10-26 21:00:00.000

请帮助我理解为什么它会改变表2的值。它应该和表1一样,因为它们的查询没有变化&源也一样吗?

hive> desc extended Final_table1;
OK
event_timestamp         timestamp
event_date              date
service_id              int

# Partition Information

# col_name              data_type               comment

event_date              date
service_id              int

Detailed Table Information      Table(tableName:Final_table1, dbName:rwdb, owner:hdfs, createTime:1496391931, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:event_timestamp, type:timestamp, comment:null), FieldSchema(name:event_date, type:date, comment:null), FieldSchema(name:service_id, type:int, comment:null)], location:hdfs://R333:8020/user/hive/warehouse/rwdb.db/Final_table1, inputFormat:org.apache.hadoop.hive.ql.io.orc.OrcInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.ql.io.orc.OrcSerde, parameters:{field.delim=,, serialization.format=,}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[FieldSchema(name:event_date, type:date, comment:null), FieldSchema(name:service_id, type:int, comment:null)], parameters:{transient_lastDdlTime=1496391931}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)

=======================================================
hive> desc extended Final_table2;
OK
event_timestamp         timestamp
event_date              date
service_id              int

# Partition Information

# col_name              data_type               comment

event_date              date
service_id              int

Detailed Table Information      Table(tableName:Final_table2, dbName:rwdb, owner:hdfs, createTime:1509000492, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:event_timestamp, type:timestamp, comment:null), FieldSchema(name:event_date, type:date, comment:null), FieldSchema(name:service_id, type:int, comment:null)], location:hdfs://R333:8020/user/hive/warehouse/rwdb.db/Final_table2, inputFormat:org.apache.hadoop.hive.ql.io.orc.OrcInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.ql.io.orc.OrcSerde, parameters:{field.delim=,, serialization.format=,}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[FieldSchema(name:event_date, type:date, comment:null), FieldSchema(name:service_id, type:int, comment:null)], parameters:{transient_lastDdlTime=1509000492}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
jxct1oxe

jxct1oxe1#

替换
“yyyy-mm-dd hh:00:00.0”与“yyyy-mm-dd hh:mm:ss.s”

相关问题