使用配置单元时间戳不接受Spark时间戳类型

问题描述 投票:1回答:1

我有一个Spark数据帧,其中包含一个字段作为时间戳。我将数据帧存储到创建hive外部表的HDFS位置。 Hive表包含具有时间戳类型的字段。但是,从外部位置配置单元读取数据时,会将时间戳字段填充为表中的空白值。我的spark数据帧查询:

df.select($"ipAddress", $"clientIdentd", $"userId", to_timestamp(unix_timestamp($"dateTime", "dd/MMM/yyyy:HH:mm:ss Z").cast("timestamp")).as("dateTime"), $"method", $"endpoint", $"protocol", $"responseCode", $"contentSize", $"referrerURL", $"browserInfo")

Hive创建表语句:

CREATE EXTERNAL TABLE `finalweblogs3`(
   `ipAddress` string,
   `clientIdentd` string,
   `userId` string,
   `dateTime` timestamp,
   `method` string,
   `endpoint` string,
   `protocol` string,
   `responseCode` string,
   `contentSize` string,
   `referrerURL` string,
   `browserInfo` string)
 ROW FORMAT SERDE
   'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
 WITH SERDEPROPERTIES (
   'field.delim'=',',
   'serialization.format'=',')
 STORED AS INPUTFORMAT
   'org.apache.hadoop.mapred.TextInputFormat'
 OUTPUTFORMAT
   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
   'hdfs://localhost:9000/streaming/spark/finalweblogs3'

我无法理解为什么会发生这种情况。

apache-spark hive spark-dataframe
1个回答
0
投票

我通过将存储格式更改为“Parquet”来解决它。我仍然不知道为什么它不适用于CSV格式。

© www.soinside.com 2019 - 2024. All rights reserved.