You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Zhen Chen (Jira)" <ji...@apache.org> on 2026/04/01 07:49:00 UTC
[jira] [Commented] (CALCITE-7187) Java UDF byte arrays cannot be mapped to VARBINARY
[ https://issues.apache.org/jira/browse/CALCITE-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18070265#comment-18070265 ]
Zhen Chen commented on CALCITE-7187:
------------------------------------
I noticed that this Jira issue doesn't seem to have a finalized solution yet. However, the corresponding PR was merged without being approved. Should we discuss the proposed solution further? Although I'm not personally familiar with this specific area, I imagine there are members of the community who are knowledgeable about this module.
> 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)