gpt4 book ai didi

azure 数据砖: java. lang.ClassNotFoundException : Failed to find data source: com. databricks.spark.xml

转载 作者:行者123 更新时间:2023-12-05 05:05:28 30 4
gpt4 key购买 nike

我正在尝试使用以下代码使用azure databricks读取xml文件:

df = spark.read.format('com.databricks.spark.xml').options(rowTag='book').load(' /FileStore/tables/sample.xml')

我安装了spark-xml:0.1.1-s_2.10包:

enter image description here

但是我遇到了以下错误:

Py4JJavaError: An error occurred while calling o285.load.
: java.lang.ClassNotFoundException: Failed to find data source: com.databricks.spark.xml. Please find packages at http://spark.apache.org/third-party-projects.html
at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:733)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:276)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:380)
at py4j.Gateway.invoke(Gateway.java:295)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:251)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.databricks.spark.xml.DefaultSource
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23$$anonfun$apply$14.apply(DataSource.scala:710)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23$$anonfun$apply$14.apply(DataSource.scala:710)
at scala.util.Try$.apply(Try.scala:192)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23.apply(DataSource.scala:710)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$23.apply(DataSource.scala:710)
at scala.util.Try.orElse(Try.scala:84)
at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:710)
... 13 more

最佳答案

您应该从 Maven 存储库下载最新版本的“spark-xml”。

安装第三方库的步骤:

第 1 步:创建 Databricks 集群。

第2步:选择创建的集群。

第三步:选择库 => 安装新的 => 选择库源 = "Maven"=> 坐标 => 搜索包 => 选择 Maven Central => 搜索所需的包。 示例: (com.databricks:spark-xml_2.12:0.9.0) => 安装

enter image description here

使用 azure databricks 读取 xml 文件,代码如下:

df = spark.read .format("com.databricks.spark.xml") .option("rowTag", "book") .load(inputFile)

更多详情,请参阅“Read XML in Spark”。

关于 azure 数据砖: java. lang.ClassNotFoundException : Failed to find data source: com. databricks.spark.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60511486/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com