[ 
https://issues.apache.org/jira/browse/CALCITE-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

hongyu guo resolved CALCITE-7187.
---------------------------------
    Resolution: Fixed

Fixed in 
[https://github.com/apache/calcite/commit/04a7832751f7d8475f5ffc9a73c80c147b6ded30].

> Java UDF byte arrays cannot be mapped to VARBINARY
> --------------------------------------------------
>
>                 Key: CALCITE-7187
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7187
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Yu Xu
>            Assignee: hongyu guo
>            Priority: Minor
>              Labels: pull-request-available
>
> When we customize a Java UDF with a return type of Byte/byte[], for example:
>  
> {code:java}
> public static class CharacterArrayFunction {
>   public static byte[] eval(String s) {
>     if (s == null) {
>       return null;
>     }
>     try {
>       return s.getBytes(StandardCharsets.UTF_8);
>     } catch (Exception e) {
>       return null;
>     }
>   }
> } {code}
> After codegen, the execution may encounter the following compatibility 
> issues. Currently, Calcite is not compatible with byte/Byte[] to ByteString:
>  
> {code:java}
> Caused by: org.codehaus.commons.compiler.CompileException: Line 22, Column 
> 65: Cannot cast "byte[]" to "org.apache.calcite.avatica.util.ByteString"   at 
> org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:13228)       
> at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5311) at 
> org.codehaus.janino.UnitCompiler.access$8800(UnitCompiler.java:240)  at 
> org.codehaus.janino.UnitCompiler$16.visitCast(UnitCompiler.java:4819)        
> at org.codehaus.janino.UnitCompiler$16.visitCast(UnitCompiler.java:4800)      
>   at org.codehaus.janino.Java$Cast.accept(Java.java:5283) at 
> org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4800)  at 
> org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5945)     
> at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2897)    at 
> org.codehaus.janino.UnitCompiler.access$2800(UnitCompiler.java:240)  at 
> org.codehaus.janino.UnitCompiler$6.visitReturnStatement(UnitCompiler.java:1594)
>       at 
> org.codehaus.janino.UnitCompiler$6.visitReturnStatement(UnitCompiler.java:1579)
>       at org.codehaus.janino.Java$ReturnStatement.accept(Java.java:3888)      
> at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1579)     at 
> org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1665) 
> {code}



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

Reply via email to