I've created a custom udf that is registered but when I try to run select do_protect('[email protected]','Test_EMAIL');
I am getting following error:
io.trino.spi.TrinoException: Exact implementation of do_protect do not match expected java types
Here is my Trino udf. I want to pass two string (VARCHAR) parameters.
@ScalarFunction("do_protect")
@Description("Return encrypted string")
@SqlType(StandardTypes.VARCHAR)
public String protectUDF(@SqlType(StandardTypes.VARCHAR) Slice slice1, @SqlType(StandardTypes.VARCHAR) Slice slice2) throws PrivaceraException {
logger.info("protectUDF get called...");
String valueForEncrypt = slice1.toString();
logger.info("AS :: valueForEncrypt :: "+valueForEncrypt);
String schemeForEncrypt = slice2.toString();
logger.info("AS :: schemeForEncrypt :: "+schemeForEncrypt);
}
The answer above is incorrect. The mapping for VARCHAR is Slice. The issue you have is that you used String as the return value type. You should change that to Slice.
I think the error is in the mapping of VARCHAR
to Slice
. Instead, I believe it should map to a string
, as such:
protectUDF(@SqlType(StandardTypes.VARCHAR) string slice1, @SqlType(StandardTypes.VARCHAR) string slice2)
I found a similar issue on Stack Overflow:
Presto Custom UDF
Which led me to an article that shows the mapping for VARCHAR
is String
"CHAR, VARCHAR, and LONGVARCHAR could have been mapped to either String or char[], but String is more appropriate for normal use."
https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/guide/jdbc/getstart/mapping.doc.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With