You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by su...@apache.org on 2024/03/05 00:55:30 UTC

(arrow-datafusion-comet) branch main updated: feat: Enable min/max for boolean type (#165)

This is an automated email from the ASF dual-hosted git repository.

sunchao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new 852b8cf  feat: Enable min/max for boolean type (#165)
852b8cf is described below

commit 852b8cfbfc200b37e3d8b4c3324f6e73cf8bf42d
Author: Huaxin Gao <hu...@gmail.com>
AuthorDate: Mon Mar 4 16:55:25 2024 -0800

    feat: Enable min/max for boolean type (#165)
---
 .../org/apache/comet/serde/QueryPlanSerde.scala    |  2 +-
 .../apache/comet/exec/CometAggregateSuite.scala    | 26 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
index a412720..b154fb6 100644
--- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
+++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
@@ -181,7 +181,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde {
 
   private def minMaxDataTypeSupported(dt: DataType): Boolean = {
     dt match {
-      case _: NumericType | DateType | TimestampType => true
+      case _: NumericType | DateType | TimestampType | BooleanType => true
       case _ => false
     }
   }
diff --git a/spark/src/test/scala/org/apache/comet/exec/CometAggregateSuite.scala b/spark/src/test/scala/org/apache/comet/exec/CometAggregateSuite.scala
index d64a3a3..c2faa65 100644
--- a/spark/src/test/scala/org/apache/comet/exec/CometAggregateSuite.scala
+++ b/spark/src/test/scala/org/apache/comet/exec/CometAggregateSuite.scala
@@ -886,6 +886,32 @@ class CometAggregateSuite extends CometTestBase with AdaptiveSparkPlanHelper {
     }
   }
 
+  test("test bool_and/bool_or") {
+    withSQLConf(CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true") {
+      Seq(true, false).foreach { bosonColumnShuffleEnabled =>
+        withSQLConf(
+          CometConf.COMET_COLUMNAR_SHUFFLE_ENABLED.key -> bosonColumnShuffleEnabled.toString) {
+          Seq(true, false).foreach { dictionary =>
+            withSQLConf("parquet.enable.dictionary" -> dictionary.toString) {
+              val table = "test"
+              withTable(table) {
+                sql(s"create table $table(a boolean, b int) using parquet")
+                sql(s"insert into $table values(true, 1)")
+                sql(s"insert into $table values(false, 2)")
+                sql(s"insert into $table values(true, 3)")
+                sql(s"insert into $table values(true, 3)")
+                // Spark maps BOOL_AND to MIN and BOOL_OR to MAX
+                checkSparkAnswerAndNumOfAggregates(
+                  s"SELECT MIN(a), MAX(a), BOOL_AND(a), BOOL_OR(a) FROM $table",
+                  2)
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
   protected def checkSparkAnswerAndNumOfAggregates(query: String, numAggregates: Int): Unit = {
     val df = sql(query)
     checkSparkAnswer(df)