Vishwanatha-HD commented on code in PR #48166:
URL: https://github.com/apache/arrow/pull/48166#discussion_r2545002332


##########
cpp/src/arrow/acero/hash_join.cc:
##########
@@ -306,12 +307,33 @@ class HashJoinBasicImpl : public HashJoinImpl {
 
     size_t num_probed_rows = match.size() + no_match.size();
     if (mask.is_scalar()) {
-      const auto& mask_scalar = mask.scalar_as<BooleanScalar>();
-      if (mask_scalar.is_valid && mask_scalar.value) {
-        // All rows passed, nothing left to do
-        return Status::OK();
+#if ARROW_LITTLE_ENDIAN
+       const auto& mask_scalar = mask.scalar_as<BooleanScalar>();
+       if (mask_scalar.is_valid && mask_scalar.value) {
+         // All rows passed, nothing left to do
+         return Status::OK();
+#else
+      // Check if the scalar is a BooleanScalar before casting
+      if (mask.scalar()->type->id() == Type::BOOL) {

Review Comment:
   @kou,
   Please find the root cause of this issue on s390x platform below:
   
   The test was failing with a std::bad_cast exception in the 
ProbeBatch_ResidualFilter function in hash_join.cc at line 309. The issue 
occurred when the code tried to cast a Datum's scalar to a BooleanScalar using:
   
   const auto& mask_scalar = mask.scalar_as<BooleanScalar>();
   
   The problem was that the test uses literal(NullScalar()) as one of the 
filter expressions, which creates a NullScalar (of type NullType), not a 
BooleanScalar (of type BoolType). When the code tried to cast this to a 
BooleanScalar, it failed with std::bad_cast on s390x architecture
   
   The Fix
   I modified the ProbeBatch_ResidualFilter function to check the scalar's type 
before attempting the cast



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