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: 

SparkException: Job aborted due to stage failure when attempting to run grid_pointascellid

kll
New Contributor III

I am attempting to apply Mosaic's `grid_pointascellid` method on a spark dataframe with `lat`, `lon` columns.

```
import pyspark.sql.functions as F

# Create a Spark DataFrame with a lat and lon column
df = spark.createDataFrame([
("point1", 10.0, 20.0),
("point2", 30.0, 40.0),
("point3", 50.0, 60.0),
], ["name", "lat", "lon"])

# Print the results of the DataFrame
df.show()

df1 = df.withColumn("id", grid_pointascellid(st_point(df["lon"], df["lat"]), lit(7)))
df1.show()

```

The schema of the dataframe is:

```

|-- name: string (nullable = true)
|-- lat: decimal(9,6) (nullable = true)
|-- lng: decimal(9,6) (nullable = true)

```

Exception:


org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 251.0 failed 4 times, most recent failure: Lost task 0.3 in stage 251.0 (TID 15016) (10.138.221.80 executor 50): java.lang.ClassCastException: org.apache.spark.sql.types.Decimal cannot be cast to java.lang.Double

https://databrickslabs.github.io/mosaic/api/spatial-indexing.html?highlight=grid_boundary#grid-point...

0 REPLIES 0
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!