【发布时间】:2020-09-19 18:31:20
【问题描述】:
请查找数据格式
c3f36c25-2546-48b2-bd72-1b5e5dcae2ab/1620247529/{6032:{"advertisers":{"Amoma":[{"eurocents":17256,"breakfast":false}]
尝试以下方法
valsschema=List(
("Userid", StringType, true),
("unix_time", IntegerType, true),
("hotelresults",MapType(IntegerType,true,StructType(("advertisers",MapType(StringType,true,ArrayType(StructType("eurocents",IntegerType,true,"breakfast",BooleanType,true))))))
)
【问题讨论】:
-
能否请您发布您的问题,并提供更清晰的信息以及您面临的异常/错误
-
我需要通过 sparkscala 为上述数据创建一个配置单元表。需要创建一个架构。我收到错误,因为方法应用的参数不足:(名称:字符串,数据类型:org.apache.spark.sql.types.DataType,可为空:布尔,元数据:org.apache.spark.sql.types.Metadata)对象 StructField 中的 org.apache.spark.sql.types.StructField。未指定值参数dataType
-
还有其他方法可以为我的数据创建架构
-
你问题中的 JSON 无效。请先更正
-
c3f36c25-2546-48b2-bd72-1b5e5dcae2ab\u00011620247529\u00016032\u0003Amoma\u000617256\bfalse => 这是原始数据,这不是 JSON 。我已经转换了它
标签: scala apache-spark hive apache-spark-sql complex-data-types