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
Prev Previous commit
Next Next commit
move analysis error tests to AnalysisSuite
  • Loading branch information
peter-toth committed Jun 13, 2019
commit f80011198337e90cad82c72460f1fd4e0bfa5b1d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogStorageFormat, CatalogTable
import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.dsl.plans._
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.parser.CatalystSqlParser.parsePlan
import org.apache.spark.sql.catalyst.plans.{Cross, Inner}
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.plans.physical.{HashPartitioning, Partitioning,
Expand Down Expand Up @@ -633,4 +634,16 @@ class AnalysisSuite extends AnalysisTest with Matchers {
val res = ViewAnalyzer.execute(view)
comparePlans(res, expected)
}

test("SPARK-28002: CTE with non-existing column alias") {
assertAnalysisError(parsePlan("WITH t(x) AS (SELECT 1) SELECT * FROM t WHERE y = 1"),
Seq("cannot resolve '`y`' given input columns: [x]"))
}

test("SPARK-28002: CTE with non-matching column alias") {
assertAnalysisError(parsePlan("WITH t(x, y) AS (SELECT 1) SELECT * FROM t WHERE x = 1"),
Seq("Number of column aliases does not match number of columns. Number of column aliases: " +
"2; number of columns: 1."))
}

}
18 changes: 0 additions & 18 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -555,24 +555,6 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
)
}

test("SPARK-28002: CTE with non-existing column alias") {
intercept[AnalysisException] {
sql("""
|WITH t(x) AS (SELECT 1)
|SELECT * FROM t WHERE y = 1
""".stripMargin)
}
}

test("SPARK-28002: CTE with non-matching column alias") {
intercept[AnalysisException] {
sql("""
|WITH t(x, y) AS (SELECT 1)
|SELECT * FROM t WHERE x = 1
""".stripMargin)
}
}

test("date row") {
checkAnswer(sql(
"""select cast("2015-01-28" as date) from testData limit 1"""),
Expand Down