cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

spark-xml not working with Databricks Connect and Pyspark

brendan-b
New Contributor II

Hi all,

I currently have a cluster configured in databricks with spark-xml (version com.databricks:spark-xml_2.12:0.13.0) which was installed using Maven. The spark-xml library itself works fine with Pyspark when I am using it in a notebook within the databricks web-app.

I often use databricks connect with Pyspark for development though. More specifically, using VS Code. Again, databricks connect works fine when I am performing commands on the cluster such as spark.read.csv.

However, when I try and run my spark-xml code from within VS code, i receive the following error:

java.lang.ClassNotFoundException: Failed to find data source: xml. Please find packages at http://spark.apache.org/third-party-projects.html

I have tried using both read formats below with no luck. I have also tried placing the spark-xml jar file that matches the version in databricks within my Pyspark jars but again it did not work.

df = spark.read.format('xml')
 
df = spark.read.format('com.databricks.spark.xml')

Any ideas how I can get my local databricks connect venv to recognise the xml data source would be much appreciated!

Thanks!

4 REPLIES 4

Kaniz_Fatma
Community Manager
Community Manager

Hi @ brendan-b username! My name is Kaniz, and I'm the technical moderator here. Great to meet you, and thanks for your question! Let's see if your peers in the community have an answer to your question first. Or else I will get back to you soon. Thanks.

sean_owen
Honored Contributor II
Honored Contributor II

Are you adding spark-xml as a dependency 'locally'? you're doing it right, and the name of the data source doesn't matter. Both are correct. You do not need to install JARs manually.

brendan-b
New Contributor II

@Sean Owen​ I do not believe I have. Do you have any documentation on how to install spark-xml locally? I have tried the following with no luck. IS this what you are referring to?

PYSPARK_HOME/bin/pyspark --packages com.databricks:spark-xml_2.12:0.13.0

Kaniz_Fatma
Community Manager
Community Manager

Hi @Brendan Banfield​ , This article describes how to read and write an XML file as an Apache Spark™ data source.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!