Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -490,7 +490,8 @@ object DDLPreprocessingUtils {
case (expected, actual) =>
if (expected.dataType.sameType(actual.dataType) &&
expected.name == actual.name &&
expected.metadata == actual.metadata) {
expected.metadata == actual.metadata &&
expected.exprId.id == actual.exprId.id) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this fix the problem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a correct change. please ignore this.

actual
} else {
// Renaming is needed for handling the following cases like
Expand Down
24 changes: 24 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2852,4 +2852,28 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
spark.sql(s"select * from spark_25084 distribute by ($distributeExprs)").count === count)
}
}

test("SPARK-25135: insert datasource table may all null when select from view") {
withTempDir { dir =>
val path = dir.getCanonicalPath
val cnt = 30
spark.range(cnt).selectExpr("cast(id as bigint) as col1", "cast(id as bigint) as col2")
.write.mode(SaveMode.Overwrite).parquet(path)
withTable("table1", "table2") {
spark.sql("CREATE TABLE table1(col1 bigint, col2 bigint) using parquet " +
s"location '$path'")

withView("view1") {
spark.sql("create view view1 as select col1, col2 from table1 where col1 > -20")

spark.sql("create table table2 (COL1 BIGINT, COL2 BIGINT) using parquet")

spark.sql("insert overwrite table table2 select COL1, COL2 from view1")

assert(spark.table("table2").count() === cnt)
checkAnswer(spark.table("table1"), spark.table("table2"))
}
}
}
}
}