Hadoop 如何在使用hdfs目录创建表时指定时间戳格式

Hadoop 如何在使用hdfs目录创建表时指定时间戳格式,hadoop,hive,hdfs,cloudera,impala,Hadoop,Hive,Hdfs,Cloudera,Impala,我的hdfs存储中的路径/to/file中有以下csv文件 1842,10/1/2017 0:02 7424,10/1/2017 4:06 我正在尝试使用以下命令创建表: create external table t ( number string, reported_time timestamp ) ROW FORMAT delimited fields terminated BY ',' LOCATION 'path/to/file'; 我可以在impala查询编

我的hdfs存储中的
路径/to/file
中有以下csv文件

1842,10/1/2017 0:02
7424,10/1/2017 4:06
我正在尝试使用以下命令创建表:

create external table t
(
number          string,
reported_time  timestamp
)
ROW FORMAT delimited fields terminated BY ',' 
LOCATION 'path/to/file';
我可以在impala查询编辑器中看到表
t
中的
reported\u time
列始终为空。我想这是因为我的时间戳不是公认的时间戳格式

问题:


如何指定时间戳列应为
dd/mm/yyyy hh:min
格式,以便它正确解析时间戳?

您不能自定义时间戳(根据我的exp*),但您可以创建具有字符串数据类型的表,然后可以将字符串转换为时间戳,如下所示:

select number,
       reported_time,
       from_unixtime(unix_timestamp(reported_time),'dd/MM/yyyy HH:mm') as reported_time
from t;