Details
-
Improvement
-
Status: Open
-
Normal
-
Resolution: Unresolved
-
None
Description
I'm using Java and can register an UDF function, and it works:
UDF1<Geometry, String> stGetUTMZone = new StGetUTMZone(); sparkSession.udf().register("ST_GetUTMZone", stGetUTMZone, DataTypes.StringType);
However, when I try registering an UDAF function, besides no compilation error is found, I get a runtime error due to datatype mismatch:
import org.locationtech.jts.geom.Geometry; import org.apache.spark.sql.Encoders; sparkSession.udf().register("ST_Safe_Union_Aggr", functions.udaf(new StSafeUnionAggregator(), Encoders.javaSerialization(Geometry.class)));
Error: cannot resolve 'ST_Safe_Union_Aggr(geom)' due to data type mismatch: argument 1 requires binary type, however, 'filteredincomingdata.geom' is of array<tinyint> type.; line 1 pos 79;
Where geom is obtained through ST_GeomFromWKT().
I tried also using Encoders.kryo() and Encoders.bean() with no success.
I could not find any doc related to registering the UDAF function in Java using the new Aggreagtor<IN, BUF, OUT> that could use an Encoder compatible with Geometry used in Sedona.