[ 
https://issues.apache.org/jira/browse/CALCITE-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18021037#comment-18021037
 ] 

Yu Xu commented on CALCITE-7187:
--------------------------------

This case returns the byte[] type, but after thinking about it carefully, I 
agree with your point of view. There is no need to support the 
Byte[]/Character[] type at present. If no one else objects, I will close the 
previous jira(https://issues.apache.org/jira/browse/CALCITE-7186) and note 'Not 
a Problem'.

> Java UDF byte/Byte array can not mapping 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
>            Priority: Minor
>
> 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