selvaganesang commented on code in PR #50141:
URL: https://github.com/apache/arrow/pull/50141#discussion_r3390276191
##########
cpp/src/gandiva/precompiled/decimal_wrapper.cc:
##########
@@ -423,11 +423,23 @@ FORCE_INLINE
char* castVARCHAR_decimal128_int64(int64_t context, int64_t x_high, uint64_t
x_low,
Review Comment:
The function name is kind of misleading. Intuitively, I thought that we are
casting varchar into decimal. It looks like it is converting decimal and int64
to varchar.
##########
cpp/src/gandiva/precompiled/decimal_wrapper.cc:
##########
@@ -423,11 +423,23 @@ FORCE_INLINE
char* castVARCHAR_decimal128_int64(int64_t context, int64_t x_high, uint64_t
x_low,
int32_t x_precision, int32_t x_scale,
int64_t out_len_param, int32_t* out_length)
{
+ if (out_len_param < 0) {
+ gdv_fn_context_set_error_msg(context, "Output buffer length can't be
negative");
+ *out_length = 0;
+ return const_cast<char*>("");
+ }
int32_t full_dec_str_len;
char* dec_str =
gdv_fn_dec_to_string(context, x_high, x_low, x_scale, &full_dec_str_len);
- int32_t trunc_dec_str_len =
- out_len_param < full_dec_str_len ? out_len_param : full_dec_str_len;
+ if (dec_str == nullptr) {
+ // Allocation failed upstream; error message is already set. Avoid copying
from
+ // an invalid buffer with a non-zero length.
+ *out_length = 0;
Review Comment:
Will the result be NULL? Curious Is this case of CAST((CAST(NULL AS
DECIMAL) AS VARCHAR) ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]