我試圖運用馬賽克的grid_pointascellid方法火花dataframe“緯度”,“朗”列。
' ' '
進口pyspark.sql。函數作為F
#創建一個火花DataFrame緯度和經度列
df = spark.createDataFrame ([
(“point1”, 10.0, 20.0),
(“卷簾窗”,30.0,40.0),
(“point3”, 50.0, 60.0),
]、[“名稱”、“緯度”、“朗”))
# DataFrame的打印結果
df.show ()
df1 = df。withColumn (“id”, grid_pointascellid (st_point (df(“朗”),df(“緯度”)),點燃(7)))
df1.show ()
' ' '
dataframe的模式是:
' ' '
| - - -名稱:字符串(nullable = true)
|——緯度:小數(9,6)(可空= true)
|——液化天然氣:小數(9,6)(可空= true)
' ' '
例外:
org.apache.spark。火花例外: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網格點……