Skip to content

Conversation

@gatorsmile
Copy link
Member

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

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

}
}

test("create view with mismatched schema") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you copy the tests? Could you file a JIRA issue to get rid of the duplication at the very least? Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for CREATE VIEW Another is for CREATE TEMP VIEW. They are testing different code paths.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without enabling Hive supports, we are unable to CREATE VIEW and then SELECT VIEW.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. You're right. I must've overlooked this no-so-little difference. Is temporary the only difference between the tests? Could we have a template test method to generate proper versions for the case? (even if it were too much for this change, it'd pave the way for more tests like this in the future). We could also have a follow-up change after this one is committed. WDYT @srowen @rxin? Is this worth the effort? I'm concerned with this duplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eventually, we will remove the functionality gap. At that moment, we need to clean the test suites and combine all the duplicate test cases.

@SparkQA
Copy link

SparkQA commented Jul 4, 2016

Test build #61733 has finished for PR 14047 at commit 6210568.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Jul 7, 2016

Merging in master/2.0.

asfgit pushed a commit that referenced this pull request Jul 7, 2016
…ed 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 <[email protected]>

Closes #14047 from gatorsmile/viewMismatchedColumns.

(cherry picked from commit ab05db0)
Signed-off-by: Reynold Xin <[email protected]>
@asfgit asfgit closed this in ab05db0 Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants