zanmato1984 commented on code in PR #51611:
URL: https://github.com/apache/arrow/pull/51611#discussion_r4339755140


##########
cpp/src/arrow/compute/kernels/scalar_nested.cc:
##########
@@ -537,6 +541,406 @@ const FunctionDoc list_element_doc(
      "is emitted. Null values emit a null in the output."),
     {"lists", "index"});
 
+// Raise the errors "equal" would when comparing these types
+Status CheckComparable(KernelContext* ctx, const std::shared_ptr<DataType>& 
values_type,
+                       const std::shared_ptr<DataType>& queries_type) {
+  ARROW_ASSIGN_OR_RAISE(auto values, MakeArrayOfNull(values_type, 1, 
ctx->memory_pool()));
+  ARROW_ASSIGN_OR_RAISE(auto queries,
+                        MakeArrayOfNull(queries_type, 1, ctx->memory_pool()));
+  return CallFunction("equal", {values, queries}, 
ctx->exec_context()).status();
+}
+
+// Null queries are matched without "equal", but must be comparable all the 
same
+Status CheckNullQueries(KernelContext* ctx, const Datum& values, const Datum& 
queries) {
+  if (queries.type()->id() == Type::NA || 
queries.type()->Equals(*values.type())) {
+    return Status::OK();
+  }
+  return CheckComparable(ctx, values.type(), queries.type());

Review Comment:
   I can reproduce this as well. Two additional cases are affected:
   
   - A scalar `list<float16>` containing `[1, null]`, with `float32` queries 
`[null, null]`, fails instead of returning `[true, true]`.
   - In the reverse direction, `list<float32>` containing `[[1], [null]]`, with 
`float16` queries `[null, null]`, fails instead of returning `[false, true]`.
   
   Could the null-query path apply the same float16 normalization as the 
ordinary comparison path?



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