From 4cd484bb78b26be766ffbe80bbca6f1586323ffb Mon Sep 17 00:00:00 2001 From: Hongze Zhang Date: Tue, 4 Jun 2024 15:36:09 +0800 Subject: [PATCH] Test cases --- .../gluten/execution/VeloxMetricsSuite.scala | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxMetricsSuite.scala b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxMetricsSuite.scala index ce8450fea423..3cbbed9512e0 100644 --- a/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxMetricsSuite.scala +++ b/backends-velox/src/test/scala/org/apache/gluten/execution/VeloxMetricsSuite.scala @@ -19,6 +19,7 @@ package org.apache.gluten.execution import org.apache.gluten.GlutenConfig import org.apache.gluten.sql.shims.SparkShimLoader +import org.apache.spark.SparkConf import org.apache.spark.sql.execution.CommandResultExec import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper import org.apache.spark.sql.internal.SQLConf @@ -52,6 +53,11 @@ class VeloxMetricsSuite extends VeloxWholeStageTransformerSuite with AdaptiveSpa super.afterAll() } + override protected def sparkConf: SparkConf = { + super.sparkConf + .set("spark.shuffle.manager", "org.apache.spark.shuffle.sort.ColumnarShuffleManager") + } + test("test sort merge join metrics") { withSQLConf( GlutenConfig.COLUMNAR_FPRCE_SHUFFLED_HASH_JOIN_ENABLED.key -> "false", @@ -164,4 +170,34 @@ class VeloxMetricsSuite extends VeloxWholeStageTransformerSuite with AdaptiveSpa } } } + + test("Metrics of window") { + runQueryAndCompare("SELECT c1, c2, sum(c2) over (partition by c1) as s FROM metrics_t1") { + df => + val window = find(df.queryExecution.executedPlan) { + case _: WindowExecTransformer => true + case _ => false + } + assert(window.isDefined) + val metrics = window.get.metrics + assert(metrics("numOutputRows").value == 100) + assert(metrics("outputVectors").value == 2) + } + } + + test("Metrics of noop filter's children") { + withSQLConf("spark.gluten.ras.enabled" -> "true") { + runQueryAndCompare("SELECT c1, c2 FROM metrics_t1 where c1 < 50") { + df => + val scan = find(df.queryExecution.executedPlan) { + case _: FileSourceScanExecTransformer => true + case _ => false + } + assert(scan.isDefined) + val metrics = scan.get.metrics + assert(metrics("rawInputRows").value == 100) + assert(metrics("outputVectors").value == 1) + } + } + } }