scala - 在 Databricks 中解析嵌套的 XML
问题描述
我正在尝试 p
我正在尝试将 XML 读入数据框中,并尝试使用如下所示的 explode 来展平数据。
val df = spark.read.format("xml").option("rowTag","on").option("inferschema","true").load("filepath") val parsxml= df .withColumn("爆炸元素”,爆炸((“prgSvc.element”)))。
我收到以下错误。
command-5246708674960:4: error: type mismatch;
found : String("prgSvc.element")
required: org.apache.spark.sql.Column
.withColumn("exploded_element", explode(("prgSvc.element")))**
Before reading the XML into the data frame, I also tried to manually assign a custom schema and read the XML file. But the output is all NULL. Could you please let me know if my approach is valid and how to resolve this issue and achieve the output.
Thank you.
解决方案
用这个
import spark.implicits._
val parsxml= df .withColumn("exploded_element", explode($"prgSvc.element"))
推荐阅读
- laravel - 如何在 Laravel Passport 中创建角色?
- docker - 在 Flask 中使用 Sentry 查找 Heroku H10 错误的原因
- angular - 配置中的 Angular 设置构建命令行参数(--host / --disable-host-check for --configuration=production)
- laravel - Dockerize Laravel 流明
- django - 从 POST 获取 form.cleaned_data 后如何将其传递给另一个视图?
- ios - Firebase 不适用于 iOS 的生产版本
- c - EOF 和未使用的二维数组的空闲部分
- javascript - ReactJs 函数调用,而是看到一个表达式 no-unused-expressions
- django - 按模型 B 对模型 A 进行排名
- javascript - 为什么我收到此错误 chrome-extension://invalid