У меня есть фрейм данных с типом двоичного столбца:
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|geometry
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|[00 00 00 00 01 03 00 00 00 01 00 00 00 0C 00 00 00 DB 98 6E 44 29 9F 27 C0 12 B5 D7 DE CB D9 3D 40 7E 31 DD 88 92 48 12 C0 C7 F3 80 F4 27 CB 3D 40 7E 04 6F 8D 40 66 11 C0 DF 8B 45 5B F0 ED 3F 40 F8 11 BC 35 42 AC FF BF E6 9B B6 D3 1F 51 41 40 FC 08 DE 1A 01 D6 01 C0 43 FC 24 9B EA C7 41 40 04 D2 43 B4 A0 4E 15 C0 BD BE 04 B3 4B EE 41 40 FB D1 43 B4 DC 6C 15 C0 D4 1E 31 AF 6E F0 41 40 FE D1 43 B4 68 FE 15 C0 1A 70 70 A3 7D F4 41 40 01 D2 43 B4 54 F2 17 C0 E6 AC DD 04 74 E8 41 40 01 D2 43 B4 F4 7B 1B C0 78 2A 87 86 EF 15 41 40 00 E9 21 5A AA 17 23 C0 B8 2D FD 64 77 6F 40 40 DB 98 6E 44 29 9F 27 C0 12 B5 D7 DE CB D9 3D 40]
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Это двоичное представление:
'POLYGON((-11.8108617196089 29.8507670666341,-4.57087148523385 29.7935784163308,-4.3498556231508 31.9294487995902,-1.97955533018205 34.6337837831159,-2.2294942950258 35.5618471079438,-5.32678491271918 35.8616851590318,-5.35631066955511 35.8783778180929,-5.4984462896723 35.9100841807378,-5.98665124572699 35.8160406191253,-6.87105065978949 34.1713722381582,-9.54622155822699 32.8708311306213,-11.8108617196089 29.8507670666341))',0
Я пытаюсь выполнить следующий код:
df.withColumn("geometry",expr("ST_GeomFromWKB(geometry)"));
Я получаю следующую ошибку:
20/08/04 10:49:35 ERROR Executor: Exception in task 87.0 in stage 40.0 (TID 930)
java.lang.ClassCastException: [B cannot be cast to org.apache.spark.unsafe.types.UTF8String
at org.apache.spark.sql.geosparksql.expressions.ST_GeomFromWKB.eval(Constructors.scala:174)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.writeFields_0_0$(Unknown Source)at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown
Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown
Source)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:410)
Когда я попробовал следующий код:
df.withColumn("geometry",hex(col("geometry")))
.withColumn("geometry",expr("ST_GeomFromWKB(geom)"));
, я получил следующий результат:
POINT(0 0)
Вместо:
'POLYGON((-11.8108617196089 29.8507670666341,-4.57087148523385 29.7935784163308,-4.3498556231508 31.9294487995902,-1.97955533018205 34.6337837831159,-2.2294942950258 35.5618471079438,-5.32678491271918 35.8616851590318,-5.35631066955511 35.8783778180929,-5.4984462896723 35.9100841807378,-5.98665124572699 35.8160406191253,-6.87105065978949 34.1713722381582,-9.54622155822699 32.8708311306213,-11.8108617196089 29.8507670666341))',0