Skip to content

Commit

Permalink
Update test.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Feb 26, 2020
1 parent 0d0e81d commit fec700f
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import org.apache.spark.{AccumulatorSuite, SparkException}
import org.apache.spark.scheduler.{SparkListener, SparkListenerJobStart}
import org.apache.spark.sql.catalyst.expressions.GenericRow
import org.apache.spark.sql.catalyst.expressions.aggregate.{Complete, Partial}
import org.apache.spark.sql.catalyst.optimizer.ConvertToLocalRelation
import org.apache.spark.sql.catalyst.optimizer.{ConvertToLocalRelation, NestedColumnAliasingSuite}
import org.apache.spark.sql.catalyst.plans.logical.Project
import org.apache.spark.sql.catalyst.util.StringUtils
import org.apache.spark.sql.execution.HiveResult.hiveResultString
import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
Expand Down Expand Up @@ -3396,13 +3397,24 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark

test("SPARK-30870: Column pruning shouldn't alias a nested column if it means the whole " +
"structure") {
val df = sql(
"""
|SELECT explodedvalue.field
|FROM VALUES array(named_struct('field', named_struct('a', 1, 'b', 2))) AS (value)
|LATERAL VIEW explode(value) AS explodedvalue
""".stripMargin)
checkAnswer(df, Row(Row(1, 2)) :: Nil)
withTable("t") {
val df = sql(
"""
|SELECT value
|FROM VALUES array(named_struct('field', named_struct('a', 1, 'b', 2))) AS (value)
""".stripMargin)
df.write.format("parquet").saveAsTable("t")

val df2 = spark.table("t")
.limit(100)
.select(size(col("value.field")))
val projects = df2.queryExecution.optimizedPlan.collect {
case p: Project => p
}
assert(projects.length == 1)
val aliases = NestedColumnAliasingSuite.collectGeneratedAliases(projects(0))
assert(aliases.length == 0)
}
}
}

Expand Down

0 comments on commit fec700f

Please sign in to comment.