bkmgit commented on a change in pull request #11882:
URL: https://github.com/apache/arrow/pull/11882#discussion_r786216564



##########
File path: cpp/src/arrow/compute/kernels/scalar_compare.cc
##########
@@ -156,39 +212,52 @@ struct Maximum {
   }
 };
 
+// Check if timestamp timezones are comparable (either all are empty or none 
is).
+Status CheckCompareTimestamps(const ExecBatch& batch) {
+  if (batch.num_values() > 0) {
+    for (int i = 0; i < batch.num_values() - 1; ++i) {
+      const auto& tsi = checked_cast<const TimestampType&>(*batch[i].type());
+      for (int j = i + 1; j < batch.num_values(); ++j) {

Review comment:
       The comparison is done using [Boolean 
algebra](https://en.wikipedia.org/wiki/Boolean_algebra#Basic_operations) which 
has the truth table:
   
   |  x  | y  |  x^y |
   |---  |---  |---    |
   |  1  | 1  |   1   |
   |  1  | 0  |   0   |
   |  0  | 1  |   0   |
   |  0  |  0 |   1   |
   
   Thus ( 1^1) ^ 1 = 0, ( 1 ^ 0 ) ^ 1 = 0 and ( 1 ^ 1 ) ^ 0 = 1 which are not 
the result we want.  To keep the code general and extensible, a double loop 
that allows for pairwise comparisons will give the correct results. 
   
   Another option could be to cast to integers, sum the results and check if 
the sum is either 0 or batch.numvalues()




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