0

我有以下数据框:

+-------------+-----------------+------------------+
|longitude    |latitude         |geom              |
+-------------+-----------------+------------------+
|-7.07378166  |33.826661        [00 00 00 00 01 0..|
|-7.5952683   |33.544191        [00 00 00 00 01 0..|                  
+-------------+-----------------+------------------+

我正在使用以下代码:

 Dataset<Row> result_f = sparkSession.sql("select * from data_f where ST_WITHIN(ST_PointFromText(CAST(data_f.latitude_f AS Decimal(24,20)), CAST(data_f.longitude_f AS Decimal(24,20))),geom)");
    result_f.show();

执行时出现以下异常:

java.lang.ClassCastException: org.apache.spark.sql.types.Decimal cannot be cast to org.apache.spark.unsafe.types.UTF8String
at org.apache.spark.sql.geosparksql.expressions.ST_PointFromText.eval(Constructors.scala:44)
at org.apache.spark.sql.geosparksql.expressions.ST_Within.eval(Predicates.scala:104)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificPredicate.And_0$(Unknown Source)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificPredicate.eval(Unknown Source)
at org.apache.spark.sql.execution.joins.CartesianProductExec$$anonfun$doExecute$1$$anonfun$2.apply(CartesianProductExec.scala:89)
at org.apache.spark.sql.execution.joins.CartesianProductExec$$anonfun$doExecute$1$$anonfun$2.apply(CartesianProductExec.scala:88)

你有什么想法吗?

我需要你的帮助 。

谢谢

4

0 回答 0