报错:Since Spark 2.3,the queries from raw JSONCSV files are disallowed when thereferenced columns

报错:Since Spark 2.3,the queries from raw JSONCSV files are disallowed when thereferenced columns,第1张

错误:Exception in thread "main" org.apache.spark.sql.AnalysisException: Since Spark 2.3, the queries from raw JSON/CSV files are disallowed when the referenced columns only include the internal corrupt record column (named _corrupt_record by default). For example: spark.read.schema(schema).json(file).filter($"_corrupt_record".isNotNull).count() and spark.read.schema(schema).json(file).select("_corrupt_record").show(). Instead, you can cache or save the parsed results and then send the same query. For example, val df = spark.read.schema(schema).json(file).cache() and then df.filter($"_corrupt_record".isNotNull).count().;

从 Spark 2.3 开始,当引用的列仅包含内部损坏记录列(默认命名为 _corrupt_record)时,不允许来自原始 JSON/CSV 文件的查询

意思是:spark读取JSON文件时必须是一行一行的格式

 Spark 在处理 json 数据时将每个新行视为一个完整的 json。

必须通过删除所有空格和换行符将完整的 json 以紧凑的形式保存在一行中。

也就是:

{
  "a": {
  "b": 1
  }
}

这样是不行的

必须是

{"a":{"b":1}}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/662122.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-18
下一篇 2022-04-18

发表评论

登录后才能评论

评论列表(0条)

保存