You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "Glauber M Dantas (Jira)" <ji...@apache.org> on 2022/11/01 15:18:00 UTC

[jira] [Created] (SEDONA-187) Register UDAF function using Java

Glauber M Dantas created SEDONA-187:
---------------------------------------

             Summary: Register UDAF function using Java
                 Key: SEDONA-187
                 URL: https://issues.apache.org/jira/browse/SEDONA-187
             Project: Apache Sedona
          Issue Type: Improvement
            Reporter: Glauber M Dantas
             Fix For: 1.2.1


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 {color:#6a8759}ST_GeomFromWKT().{color}}}

 
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.}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)