Skip to content

Conversation

@gatorsmile
Copy link
Member

What changes were proposed in this pull request?

When doing a CTAS with a Partition By clause, we got a wrong error message.

For example,

CREATE TABLE gen__tmp
PARTITIONED BY (key string)
AS SELECT key, value FROM mytable1

The error message we get now is like

Operation not allowed: Schema may not be specified in a Create Table As Select (CTAS) statement(line 2, pos 0)

However, based on the code, the message we should get is like

Operation not allowed: A Create Table As Select (CTAS) statement is not allowed to create a partitioned table using Hive's file formats. Please use the syntax of "CREATE TABLE tableName USING dataSource OPTIONS (...) PARTITIONED BY ...\" to create a partitioned table through a CTAS statement.(line 2, pos 0)

Currently, partitioning columns is part of the schema. This PR fixes the bug by changing the detection orders.

How was this patch tested?

Added test cases.

ctx)
}
// Hive does not allow to use a CTAS statement to create a partitioned table.
if (tableDesc.partitionColumnNames.nonEmpty) {
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 a dead code if we do not change the order.

@SparkQA
Copy link

SparkQA commented Jul 9, 2016

Test build #62013 has finished for PR 14113 at commit 55b1a8c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Jul 9, 2016

Test build #62026 has finished for PR 14113 at commit 55b1a8c.

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

@gatorsmile
Copy link
Member Author

wrong branch... Let me revert it back

@SparkQA
Copy link

SparkQA commented Jul 10, 2016

Test build #62046 has finished for PR 14113 at commit 26bddfd.

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

@SparkQA
Copy link

SparkQA commented Jul 10, 2016

Test build #62045 has finished for PR 14113 at commit 568f133.

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

@gatorsmile
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Jul 12, 2016

Test build #62181 has finished for PR 14113 at commit 26bddfd.

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

@gatorsmile
Copy link
Member Author

cc @cloud-fan

@gatorsmile
Copy link
Member Author

retest this please

@gatorsmile
Copy link
Member Author

gatorsmile commented Aug 4, 2016

cc @cloud-fan This is not contained in #14482. Should I leave it open? or you will merge it into the PR?

@SparkQA
Copy link

SparkQA commented Aug 4, 2016

Test build #63237 has finished for PR 14113 at commit 26bddfd.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

can you update it? thanks!

@gatorsmile
Copy link
Member Author

Will update it tonight. Thanks!

@cloud-fan
Copy link
Contributor

LGTM, pending jenkins

@SparkQA
Copy link

SparkQA commented Aug 8, 2016

Test build #63343 has finished for PR 14113 at commit a518218.

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

@cloud-fan
Copy link
Contributor

thanks, merging to master and 2.0!

asfgit pushed a commit that referenced this pull request Aug 8, 2016
…lause

#### What changes were proposed in this pull request?
When doing a CTAS with a Partition By clause, we got a wrong error message.

For example,
```SQL
CREATE TABLE gen__tmp
PARTITIONED BY (key string)
AS SELECT key, value FROM mytable1
```
The error message we get now is like
```
Operation not allowed: Schema may not be specified in a Create Table As Select (CTAS) statement(line 2, pos 0)
```

However, based on the code, the message we should get is like
```
Operation not allowed: A Create Table As Select (CTAS) statement is not allowed to create a partitioned table using Hive's file formats. Please use the syntax of "CREATE TABLE tableName USING dataSource OPTIONS (...) PARTITIONED BY ...\" to create a partitioned table through a CTAS statement.(line 2, pos 0)
```

Currently, partitioning columns is part of the schema. This PR fixes the bug by changing the detection orders.

#### How was this patch tested?
Added test cases.

Author: gatorsmile <[email protected]>

Closes #14113 from gatorsmile/ctas.

(cherry picked from commit ab12690)
Signed-off-by: Wenchen Fan <[email protected]>
@asfgit asfgit closed this in ab12690 Aug 8, 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.

3 participants