Skip to content

Commit

Permalink
tpcds - pass 3.3 ut
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaichen committed Jul 30, 2024
1 parent 86413ba commit 428a65f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.apache.gluten.execution

import org.apache.gluten.GlutenConfig
import org.apache.gluten.benchmarks.GenTPCDSTableScripts
import org.apache.gluten.utils.UTSystemParameters
import org.apache.gluten.utils.{Arm, UTSystemParameters}

import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging
Expand Down Expand Up @@ -46,8 +46,8 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
rootPath + "../../../../gluten-core/src/test/resources/tpcds-queries/tpcds.queries.original"
protected val queriesResults: String = rootPath + "tpcds-decimal-queries-output"

/** Return values: (sql num, is fall back, skip fall back assert) */
def tpcdsAllQueries(isAqe: Boolean): Seq[(String, Boolean, Boolean)] =
/** Return values: (sql num, is fall back) */
def tpcdsAllQueries(isAqe: Boolean): Seq[(String, Boolean)] =
Range
.inclusive(1, 99)
.flatMap(
Expand All @@ -57,37 +57,34 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
} else {
Seq("q" + "%d".format(queryNum))
}
val noFallBack = queryNum match {
val native = queryNum match {
case i if !isAqe && (i == 10 || i == 16 || i == 35 || i == 94) =>
// q10 smj + existence join
// q10, q35 smj + existence join
// q16 smj + left semi + not condition
// q35 smj + existence join
// Q94 BroadcastHashJoin, LeftSemi, NOT condition
(false, false)
false
case i if isAqe && (i == 16 || i == 94) =>
(false, false)
case other => (true, false)
false
case _ => true
}
sqlNums.map((_, noFallBack._1, noFallBack._2))
sqlNums.map((_, native))
})

// FIXME "q17", stddev_samp inconsistent results, CH return NaN, Spark return null
protected def excludedTpcdsQueries: Set[String] = Set(
"q61", // inconsistent results
"q66", // inconsistent results
"q67" // inconsistent results
"q66" // inconsistent results
)

def executeTPCDSTest(isAqe: Boolean): Unit = {
tpcdsAllQueries(isAqe).foreach(
s =>
if (excludedTpcdsQueries.contains(s._1)) {
ignore(s"TPCDS ${s._1.toUpperCase()}") {
runTPCDSQuery(s._1, noFallBack = s._2, skipFallBackAssert = s._3) { df => }
runTPCDSQuery(s._1, noFallBack = s._2) { df => }
}
} else {
test(s"TPCDS ${s._1.toUpperCase()}") {
runTPCDSQuery(s._1, noFallBack = s._2, skipFallBackAssert = s._3) { df => }
val tag = if (s._2) "Native" else "Vanilla"
test(s"TPCDS[$tag] ${s._1.toUpperCase()}") {
runTPCDSQuery(s._1, noFallBack = s._2) { df => }
}
})
}
Expand Down Expand Up @@ -152,7 +149,7 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
}

override protected def afterAll(): Unit = {
ClickhouseSnapshot.clearAllFileStatusCache
ClickhouseSnapshot.clearAllFileStatusCache()
DeltaLog.clearCache()

try {
Expand Down Expand Up @@ -183,11 +180,10 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
tpcdsQueries: String = tpcdsQueries,
queriesResults: String = queriesResults,
compareResult: Boolean = true,
noFallBack: Boolean = true,
skipFallBackAssert: Boolean = false)(customCheck: DataFrame => Unit): Unit = {
noFallBack: Boolean = true)(customCheck: DataFrame => Unit): Unit = {

val sqlFile = tpcdsQueries + "/" + queryNum + ".sql"
val sql = Source.fromFile(new File(sqlFile), "UTF-8").mkString
val sql = Arm.withResource(Source.fromFile(new File(sqlFile), "UTF-8"))(_.mkString)
val df = spark.sql(sql)

if (compareResult) {
Expand All @@ -212,13 +208,13 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
// using WARN to guarantee printed
log.warn(s"query: $queryNum, finish comparing with saved result")
} else {
val start = System.currentTimeMillis();
val start = System.currentTimeMillis()
val ret = df.collect()
// using WARN to guarantee printed
log.warn(s"query: $queryNum skipped comparing, time cost to collect: ${System
.currentTimeMillis() - start} ms, ret size: ${ret.length}")
}
WholeStageTransformerSuite.checkFallBack(df, noFallBack, skipFallBackAssert)
WholeStageTransformerSuite.checkFallBack(df, noFallBack)
customCheck(df)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class GlutenClickHouseTPCDSParquetSuite extends GlutenClickHouseTPCDSAbstractSui
| )
|)
|""".stripMargin) { _ => }
assertResult(791809)(result.head.getLong(0))
assertResult(791909)(result.head.getLong(0))
}

test("test union operator with two tables") {
Expand Down

0 comments on commit 428a65f

Please sign in to comment.