Skip to content

Commit

Permalink
add compare with spark
Browse files Browse the repository at this point in the history
  • Loading branch information
loneylee committed Jul 9, 2024
1 parent adf7cb0 commit f2947b3
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
import org.apache.spark.sql.delta.{ClickhouseSnapshot, DeltaLog}
import org.apache.spark.sql.types.{StructField, StructType}
import org.apache.spark.sql.types.StructField

import org.apache.commons.io.FileUtils

Expand Down Expand Up @@ -199,7 +199,8 @@ abstract class GlutenClickHouseTPCDSAbstractSuite
skipFallBackAssert: Boolean = false)(customCheck: DataFrame => Unit): Unit = {

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

if (compareResult) {
val fields = new util.ArrayList[StructField]()
Expand All @@ -211,13 +212,7 @@ abstract class GlutenClickHouseTPCDSAbstractSuite

var expectedAnswer: Seq[Row] = null
withSQLConf(vanillaSparkConfs(): _*) {
expectedAnswer = spark.read
.option("delimiter", "|-|")
.option("nullValue", "null")
.schema(StructType.apply(fields))
.csv(queriesResults + "/" + queryNum + ".out")
.toDF()
.collect()
expectedAnswer = spark.sql(sql).collect()
}
checkAnswer(df, expectedAnswer)
// using WARN to guarantee printed
Expand Down

0 comments on commit f2947b3

Please sign in to comment.