Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL] Verify empty2null is offloaded when v1writer fallback #6859

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.spark.sql.sources

import org.apache.gluten.execution.SortExecTransformer
import org.apache.gluten.execution.{ProjectExecTransformer, SortExecTransformer}
import org.apache.gluten.extension.GlutenPlan

import org.apache.spark.SparkConf
Expand Down Expand Up @@ -147,6 +147,36 @@ class GlutenInsertSuite
assert(parts == expectedPartitionNames)
}

testGluten("offload empty2null when v1writes fallback") {
withSQLConf((SQLConf.MAX_RECORDS_PER_FILE.key, "1000")) {
withTable("pt") {
spark.sql("CREATE TABLE pt (c1 int) USING PARQUET PARTITIONED BY(p string)")

val df = spark.sql(s"""
|INSERT OVERWRITE TABLE pt PARTITION(p)
|SELECT c1, c2 as p FROM source
|""".stripMargin)

val writeFiles = stripAQEPlan(
df.queryExecution.executedPlan
.asInstanceOf[CommandResultExec]
.commandPhysicalPlan).children.head
assert(!writeFiles.isInstanceOf[ColumnarWriteFilesExec])
assert(writeFiles.exists(_.isInstanceOf[ProjectExecTransformer]))
val projectExecTransformer = writeFiles
.find(_.isInstanceOf[ProjectExecTransformer])
.get
.asInstanceOf[ProjectExecTransformer]
projectExecTransformer.projectList.find(_.toString().contains("empty2null"))

// The partition column should never be empty
checkAnswer(
spark.sql("SELECT * FROM pt"),
spark.sql("SELECT c1, if(c2 = '', null, c2) FROM source"))
}
}
}

testGluten("remove v1writes sort and project") {
// Only string type has empty2null expression
withTable("pt") {
Expand Down
Loading