projjal commented on a change in pull request #10023:
URL: https://github.com/apache/arrow/pull/10023#discussion_r622719721
##########
File path: cpp/src/gandiva/context_helper.cc
##########
@@ -69,6 +69,11 @@ uint8_t* gdv_fn_context_arena_malloc(int64_t context_ptr,
int32_t size) {
return context->arena()->Allocate(size);
}
+uint8_t* gdv_fn_context_arena_malloc_int64(int64_t context_ptr, int64_t size) {
Review comment:
why not keep only one method.
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -216,6 +216,72 @@ SHA_VAR_LEN_PARAMS(SHA1_HASH_FUNCTION_BUF)
#undef SHA_NUMERIC_BOOL_DATE_PARAMS
#undef SHA_VAR_LEN_PARAMS
+// Add functions for castVARBINARY for utf8 and binary
+#define CAST_VARBINARY_FROM_STRING_AND_BINARY(TYPE_NAME)
\
+ GANDIVA_EXPORT
\
+ const char* gdv_fn_castVARBINARY_##TYPE_NAME(int64_t context, const char*
data, \
+ int32_t data_len, int64_t
out_len, \
+ int64_t* out_length) {
\
+ if (out_len < 0) {
\
+ gdv_fn_context_set_error_msg(context, "Output buffer length can't be
negative"); \
+ *out_length = 0;
\
+ return "";
\
+ }
\
+
\
+ if (out_len >= data_len || out_len == 0) {
\
+ *out_length = data_len;
\
+ } else {
\
+ *out_length = out_len;
\
+ }
\
+ return data;
\
+ }
+
+CAST_VARBINARY_FROM_STRING_AND_BINARY(utf8)
+CAST_VARBINARY_FROM_STRING_AND_BINARY(binary)
+
+#undef CAST_VARBINARY_FROM_STRING_AND_BINARY
+
+// Add functions for castVARBINARY for numeric
+#define CAST_VARBINARY_FROM_NUMERIC(TYPE_NAME)
\
+ GANDIVA_EXPORT
\
+ const char* gdv_fn_castVARBINARY_##TYPE_NAME(int64_t context,
gdv_##TYPE_NAME value, \
Review comment:
I think you should return the the bytes corresponding to the string
representation of int/float. (opposite of what the change castINT from
varbinary is doing)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]