Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cpp/src/arrow/util/value_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ inline uint8_t ParseDecimalDigit(char c) { return static_cast<uint8_t>(c - '0');

#define PARSE_UNSIGNED_ITERATION(C_TYPE) \
if (length > 0) { \
if (*s == '.') { \
break; \
} \
uint8_t digit = ParseDecimalDigit(*s++); \
result = static_cast<C_TYPE>(result * 10U); \
length--; \
Expand All @@ -175,6 +178,9 @@ inline uint8_t ParseDecimalDigit(char c) { return static_cast<uint8_t>(c - '0');
/* Overflow */ \
return false; \
} \
if (*s == '.') { \
break; \
} \
uint8_t digit = ParseDecimalDigit(*s++); \
result = static_cast<C_TYPE>(result * 10U); \
C_TYPE new_result = static_cast<C_TYPE>(result + digit); \
Expand Down
18 changes: 10 additions & 8 deletions cpp/src/gandiva/gdv_function_stubs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ TEST(TestGdvFnStubs, TestCastINT) {
::testing::HasSubstr("Failed to cast the string -2147483649 to int32"));
ctx.Reset();

gdv_fn_castINT_utf8(ctx_ptr, "12.34", 5);
EXPECT_THAT(ctx.get_error(),
::testing::HasSubstr("Failed to cast the string 12.34 to int32"));
ctx.Reset();
// gdv_fn_castINT_utf8(ctx_ptr, "12.34", 5);
// EXPECT_THAT(ctx.get_error(),
// ::testing::HasSubstr("Failed to cast the string 12.34 to int32"));
// ctx.Reset();
EXPECT_EQ(gdv_fn_castINT_utf8(ctx_ptr, "12.34", 5), 12);

gdv_fn_castINT_utf8(ctx_ptr, "abc", 3);
EXPECT_THAT(ctx.get_error(),
Expand Down Expand Up @@ -97,10 +98,11 @@ TEST(TestGdvFnStubs, TestCastBIGINT) {
::testing::HasSubstr("Failed to cast the string -9223372036854775809 to int64"));
ctx.Reset();

gdv_fn_castBIGINT_utf8(ctx_ptr, "12.34", 5);
EXPECT_THAT(ctx.get_error(),
::testing::HasSubstr("Failed to cast the string 12.34 to int64"));
ctx.Reset();
// gdv_fn_castBIGINT_utf8(ctx_ptr, "12.34", 5);
// EXPECT_THAT(ctx.get_error(),
// ::testing::HasSubstr("Failed to cast the string 12.34 to int64"));
// ctx.Reset();
EXPECT_EQ(gdv_fn_castINT_utf8(ctx_ptr, "12.34", 5), 12);

gdv_fn_castBIGINT_utf8(ctx_ptr, "abc", 3);
EXPECT_THAT(ctx.get_error(),
Expand Down