DenisTarasyuk commented on code in PR #46709:
URL: https://github.com/apache/arrow/pull/46709#discussion_r2143826032


##########
cpp/src/gandiva/tests/decimal_test.cc:
##########
@@ -1237,4 +1238,43 @@ TEST_F(TestDecimal, TestSha) {
     EXPECT_NE(value_at_position, response->GetScalar(i - 
1).ValueOrDie()->ToString());
   }
 }
+
+TEST_F(TestDecimal, TestCastDecimalVarCharInvalidInputInvalidOutput) {
+  auto decimal_type_10_0 = std::make_shared<arrow::Decimal128Type>(10, 0);
+  auto decimal_type_38_30 = std::make_shared<arrow::Decimal128Type>(38, 30);
+  auto decimal_type_38_27 = std::make_shared<arrow::Decimal128Type>(38, 27);
+
+  auto field_str = field("in_str", utf8());
+  auto schema = arrow::schema({field_str});
+  auto res_bool = field("res_bool", arrow::boolean());
+
+  auto int_literal = TreeExprBuilder::MakeLiteral(static_cast<int32_t>(100));
+  auto int_literal_multiply = 
TreeExprBuilder::MakeLiteral(static_cast<int32_t>(10));
+  auto string_literal = TreeExprBuilder::MakeStringLiteral("foo");
+  auto cast_multiply_literal = TreeExprBuilder::MakeFunction(
+      "castDECIMAL", {int_literal_multiply}, decimal_type_10_0);
+  auto cast_int_literal =
+      TreeExprBuilder::MakeFunction("castDECIMAL", {int_literal}, 
decimal_type_38_30);
+  auto cast_string_func =
+      TreeExprBuilder::MakeFunction("castDECIMAL", {string_literal}, 
decimal_type_38_30);
+  auto multiply_func = TreeExprBuilder::MakeFunction(
+      "multiply", {cast_multiply_literal, cast_int_literal}, 
decimal_type_38_27);
+  auto equal_func = TreeExprBuilder::MakeFunction(
+      "equal", {multiply_func, cast_string_func}, arrow::boolean());
+  auto expr = TreeExprBuilder::MakeExpression(equal_func, res_bool);

Review Comment:
   Added comment in code.
   equal(multiply(castDecimal(10), castDecimal(100)), castDECIMAL("foo"))
   This is minimal expression I have found to be able to reproduce SIGSEGV. If 
I remove elements from it crash won't happen.
   I would like to make short test with just castDECIMAL but in case of parse 
error I can't extract returned 0 values in test.



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

Reply via email to