【发布时间】:2017-05-09 08:31:48
【问题描述】:
我正在从 hive 表中为下面的数据集构建架构。
处理后我必须将数据写入 S3。
我需要根据要准备的带有日期的json图像格式对用户ID交互进行重组和分组。
为了构建这个架构,我准备了一个带有数组的结构类型。
fields = [
StructField("expUserId", StringType(), True),
StructField("recordDate", StringType(), True),
StructField("siteId", StringType(), True),
StructField("siteName", StringType(), True),
StructField("itineraryNumber", StringType(), True),
StructField("travelStartDate", StringType(), True),
StructField("travelEndDate", StringType(), True),
StructField("destinationID", StringType(), True),
StructField("lineOfBusiness", StringType(), True),
StructField("pageViewMap", MapType(StringType(),ArrayType(StructType([
StructField("PageId", StringType(), True),
StructField("count", LongType(), True)]))), True)
]
schema = StructType(fields)
return schema
此架构是否正确?如何将 DataFrame 转换为以下 json 模式类型。
【问题讨论】:
-
能否请您替换屏幕截图并使用复制原始文本。给你一些关于如何处理数据集的额外提示会容易得多。谢谢!
标签: apache-spark pyspark apache-spark-sql apache-spark-dataset apache-spark-2.0