jpedroantunes commented on a change in pull request #10023:
URL: https://github.com/apache/arrow/pull/10023#discussion_r622948149



##########
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:
       If I get it correctly, I should do the same as the castVARCHAR for 
numeric types, but returning the correspondent bytes, correct?




-- 
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]


Reply via email to