Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Special holiday offer! You and a friend can attend FabCon with a BOGO code. Supplies are limited. Register now.

Reply
smpa01
Super User
Super User

Spark Dataset API error

I am getting the following error with dataset API but not with dataframe API in notebook.

 

 

// works
val df= Seq(
    ("Boston", "USA", 0.67),
    ("Dubai", "UAE", 3.1),
    ("Cordoba", "Argentina", 1.39)    
).toDF("city", "country", "population")

df.show()

//does not work
case class City(englishName: String, continent: String)

val cities = Seq(
  City("bejing", "asia"),
  City("new york", "north america"),
  City("paris", "europe")
).toDS()

cities.show()

// does not work
case class City(englishName: String, continent: String)
val cities2 = spark.createDataset(
  Seq(
    City("bejing", "asia"),
    City("new york", "north america"),
    City("paris", "europe")
  )
)

 

 

 

 

smpa01_0-1700508583747.png

 

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
5 REPLIES 5
v-cboorla-msft
Microsoft Employee
Microsoft Employee

Hi @smpa01 

 

Thanks for using Fabric Community.
At this time, we are reaching out to the internal team to get some help on this.
We will update you once we hear back from them.
Thanks

Hi @smpa01 

 

Apologies for the delay in response.

 

Define case class in a separate jar. Example:

1) create a jar file from .scala (ensure same scala version while compiling, see Fabric Spark runtimes (Apache Spark runtime in Fabric - Microsoft Fabric | Microsoft Learn)

package com.example

case class City(englishName: String, continent: String)

2) e.g. you can upload the jar from notebook resources (How to use notebooks - Microsoft Fabric | Microsoft Learn) and then load it: %load_new_custom_jar {mssparkutils.nbResPath}/builtin/City.jar

3) import: import com.example.City

 

I hope this helps. If you have any further questions please do let us know.

@v-cboorla-msft  i will try and let you know.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01 

 

We haven’t heard from you on the last response and was just checking back to see, did you got a chance to look into this?

In case if you have any resolution please do share that same with the community as it can be helpful to others.
Otherwise, will respond back with the more details and we will try to help.


Thanks

Hi @smpa01 

 

We haven’t heard from you on the last response and was just checking back to see, did you got a chance to look into this?

In case if you have any resolution please do share that same with the community as it can be helpful to others.
If you have any question relating to the current thread, please do let us know and we will try out best to help you.
In case if you have any other question on a different issue, we request you to open a new thread.


Thanks

Helpful resources

Announcements
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors