用spark读取多个json模式。

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

软件配置。

Hadoop distribution:Amazon 2.8.3
Applications:Hive 2.3.2, Pig 0.17.0, Hue 4.1.0, Spark 2.3.0

尝试用多个json模式读取。

val df = spark.read.option("mergeSchema", "true").json("s3a:/s3bucket20180101*")

抛出一个错误。

org.apache.spark.sql.AnalysisException: Unable to infer schema for JSON. It must be specified manually.;
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$9.apply(DataSource.scala:207)
  at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$9.apply(DataSource.scala:207)
  at scala.Option.getOrElse(Option.scala:121)
  at org.apache.spark.sql.execution.datasources.DataSource.getOrInferFileFormatSchema(DataSource.scala:206)
  at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:392)
  at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:239)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:227)
  at org.apache.spark.sql.DataFrameReader.json(DataFrameReader.scala:397)
  at org.apache.spark.sql.DataFrameReader.json(DataFrameReader.scala:340)

如何用spark读取json与multipl schema的?

json scala amazon-web-services hadoop2 amazon-emr
1个回答
0
投票

当你指向错误的路径时,有时会发生这种情况(当数据不存在时)。

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