-
- Downloads
[SPARK-16368][SQL] Fix Strange Errors When Creating View With Unmatched Column Num
#### What changes were proposed in this pull request? When creating a view, a common user error is the number of columns produced by the `SELECT` clause does not match the number of column names specified by `CREATE VIEW`. For example, given Table `t1` only has 3 columns ```SQL create view v1(col2, col4, col3, col5) as select * from t1 ``` Currently, Spark SQL reports the following error: ``` requirement failed java.lang.IllegalArgumentException: requirement failed at scala.Predef$.require(Predef.scala:212) at org.apache.spark.sql.execution.command.CreateViewCommand.run(views.scala:90) ``` This error message is very confusing. This PR is to detect the error and issue a meaningful error message. #### How was this patch tested? Added test cases Author: gatorsmile <gatorsmile@gmail.com> Closes #14047 from gatorsmile/viewMismatchedColumns.
Showing
- sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala 5 additions, 1 deletion.../scala/org/apache/spark/sql/execution/command/views.scala
- sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala 23 additions, 0 deletions...ala/org/apache/spark/sql/execution/command/DDLSuite.scala
- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala 23 additions, 0 deletions...la/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
Please register or sign in to comment