Skip to content
Permalink
Browse files

[SPARK-23312][SQL][FOLLOWUP] add a config to turn off vectorized cach…

…e reader

## What changes were proposed in this pull request?

#20483 tried to provide a way to turn off the new columnar cache reader, to restore the behavior in 2.2. However even we turn off that config, the behavior is still different than 2.2.

If the output data are rows, we still enable whole stage codegen for the scan node, which is different with 2.2, we should also fix it.

## How was this patch tested?

existing tests.

Author: Wenchen Fan <wenchen@databricks.com>

Closes #20513 from cloud-fan/cache.

(cherry picked from commit ac7454c)
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
  • Loading branch information...
cloud-fan authored and gatorsmile committed Feb 6, 2018
1 parent 7782fd0 commit 036a04b29c818ddbe695f7833577781e8bb16d3f
@@ -61,6 +61,9 @@ case class InMemoryTableScanExec(
}) && !WholeStageCodegenExec.isTooManyFields(conf, relation.schema)
}

// TODO: revisit this. Shall we always turn off whole stage codegen if the output data are rows?
override def supportCodegen: Boolean = supportsBatch

override protected def needsUnsafeRowConversion: Boolean = false

private val columnIndices =
@@ -787,7 +787,8 @@ class CachedTableSuite extends QueryTest with SQLTestUtils with SharedSQLContext
withSQLConf(SQLConf.CACHE_VECTORIZED_READER_ENABLED.key -> vectorized.toString) {
val df = spark.range(10).cache()
df.queryExecution.executedPlan.foreach {
case i: InMemoryTableScanExec => assert(i.supportsBatch == vectorized)
case i: InMemoryTableScanExec =>
assert(i.supportsBatch == vectorized && i.supportCodegen == vectorized)
case _ =>
}
}
@@ -137,7 +137,7 @@ class WholeStageCodegenSuite extends QueryTest with SharedSQLContext {
val dsStringFilter = dsString.filter(_ == "1")
val planString = dsStringFilter.queryExecution.executedPlan
assert(planString.collect {
case WholeStageCodegenExec(FilterExec(_, i: InMemoryTableScanExec)) if !i.supportsBatch => ()
case i: InMemoryTableScanExec if !i.supportsBatch => ()
}.length == 1)
assert(dsStringFilter.collect() === Array("1"))
}

0 comments on commit 036a04b

Please sign in to comment.
You can’t perform that action at this time.