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


##########
cpp/src/gandiva/tests/decimal_test.cc:
##########
@@ -1237,4 +1237,42 @@ 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((int32_t)100);
+    auto int_literal_multiply = TreeExprBuilder::MakeLiteral((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:
   Strange. Fix works on my machine. Also test was green in this PR and also 
tried in docker x86 env.
   
   > [ RUN      ] TestDecimal.TestCastDecimalVarCharInvalidInputInvalidOutput
   > /arrow2/cpp/src/gandiva/cache.cc:58: Creating gandiva cache with capacity 
of 5000
   > /arrow2/cpp/src/gandiva/engine.cc:282: Detected CPU Name : znver2
   > /arrow2/cpp/src/gandiva/engine.cc:283: Detected CPU Features: [ +prfchw 
-cldemote +avx +aes +sahf +pclmul -xop +crc32 +xsaves -avx512fp16 -sm4 +sse4.1 
-avx512ifma +xsave -avx512pf +sse4.2 -tsxldtrk -ptwrite -widekl -sm3 -invpcid 
+64bit +xsavec -avx512vpopcntdq +cmov -avx512vp2intersect -avx512cd +movbe 
-avxvnniint8 -avx512er -amx-int8 -kl -sha512 -avxvnni -rtm +adx +avx2 -hreset 
-movdiri -serialize -vpclmulqdq -avx512vl -uintr +clflushopt -raoint -cmpccxadd 
+bmi -amx-tile +sse -gfni -avxvnniint16 -amx-fp16 +xsaveopt +rdrnd -avx512f 
-amx-bf16 -avx512bf16 -avx512vnni +cx8 -avx512bw +sse3 -pku +fsgsbase +clzero 
-mwaitx -lwp +lzcnt +sha -movdir64b -wbnoinvd -enqcmd -prefetchwt1 
-avxneconvert -tbm -pconfig -amx-complex +ssse3 +cx16 +bmi2 +fma +popcnt 
-avxifma +f16c -avx512bitalg -rdpru +clwb +mmx +sse2 +rdseed -avx512vbmi2 
-prefetchi +rdpid -fma4 -avx512vbmi -shstk -vaes -waitpkg -sgx +fxsr -avx512dq 
+sse4a]
   > 
   > Thread 1 "gandiva-project" received signal SIGSEGV, Segmentation fault.
   > 0x00007ffff786fdfc in ?? ()
   > (gdb) bt
   > #0  0x00007ffff786fdfc in ?? ()
   > #1  0x00007fffffffd700 in ?? ()
   > #2  0x0000000108b76b98 in ?? ()
   > #3  0x0000000c9f2c9cd0 in ?? ()
   > #4  0x4674edea40000000 in ?? ()
   > #5  0x4674edea40000000 in ?? ()
   > #6  0x0000000c9f2c9cd0 in ?? ()
   > #7  0x85acef8100000000 in ?? ()
   > #8  0x000004ee2d6d415b in ?? ()
   > #9  0x00007fffffffd6b0 in ?? ()
   > #10 0x0000000002064191 in std::_Tuple_impl<0ul, unsigned char**, 
std::default_delete<unsigned char* []> >::_M_head (__t=...)
   >     at /opt/rh/devtoolset-10/root/usr/include/c++/10/tuple:204
   > #11 0x000000000203d925 in gandiva::Projector::Evaluate (this=0x8d66a50, 
batch=..., selection_vector=0x0, pool=0x8768f40 <arrow::global_state+576>, 
output=0x7fffffffdaa0)
   >     at /arrow2/cpp/src/gandiva/projector.cc:176
   > #12 0x000000000203d5e5 in gandiva::Projector::Evaluate (this=0x8d66a50, 
batch=..., pool=0x8768f40 <arrow::global_state+576>, output=0x7fffffffdaa0)
   >     at /arrow2/cpp/src/gandiva/projector.cc:154
   > #13 0x0000000001f9ea88 in 
gandiva::TestDecimal_TestCastDecimalVarCharInvalidInputInvalidOutput_Test::TestBody
 (this=0x8aedb20)
   >     at /arrow2/cpp/src/gandiva/tests/decimal_test.cc:1207



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to