-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7187] Java UDF byte arrays cannot be mapped to VARBINARY #4855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,7 @@ | |||||||||||
| import java.io.IOException; | ||||||||||||
| import java.lang.reflect.Method; | ||||||||||||
| import java.math.BigDecimal; | ||||||||||||
| import java.nio.charset.StandardCharsets; | ||||||||||||
| import java.sql.Date; | ||||||||||||
| import java.sql.Time; | ||||||||||||
| import java.sql.Timestamp; | ||||||||||||
|
|
@@ -1493,6 +1494,23 @@ public static ByteString eval(String s) { | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** User-defined function with return type byte[]. */ | ||||||||||||
| public static class ByteArrayFunction { | ||||||||||||
| public static byte[] eval(String s) { | ||||||||||||
| if (s == null) { | ||||||||||||
| return null; | ||||||||||||
| } | ||||||||||||
| return s.getBytes(StandardCharsets.UTF_8); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** User-defined function with parameter type byte[]. */ | ||||||||||||
| public static class ByteArrayLengthFunction { | ||||||||||||
| public static int eval(byte[] bytes) { | ||||||||||||
|
||||||||||||
| public static int eval(byte[] bytes) { | |
| public static @Nullable Integer eval(@Nullable byte[] bytes) { | |
| if (bytes == null) { | |
| return null; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UDF in Smalls is just for test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc mentions
ByteStringwithout qualification; since there are multiple ByteString types in the Java ecosystem, consider using the fully qualified name (org.apache.calcite.avatica.util.ByteString) or linking to the API docs to avoid ambiguity. Also, the sentence aboutByte[]could be misread as "not supported at all"; if the intent is "not supported as a VARBINARY representation", consider stating that explicitly.