Skip to content

Conversation

@gengliangwang
Copy link
Member

What changes were proposed in this pull request?

This PR is to finish #17272

This JIRA is a follow up work after SPARK-19583

As we discussed in that PR

The following DDL for a managed table with an existed default location should throw an exception:

CREATE TABLE ... (PARTITIONED BY ...) AS SELECT ...
CREATE TABLE ... (PARTITIONED BY ...)
Currently there are some situations which are not consist with above logic:

CREATE TABLE ... (PARTITIONED BY ...) succeed with an existed default location
situation: for both hive/datasource(with HiveExternalCatalog/InMemoryCatalog)

CREATE TABLE ... (PARTITIONED BY ...) AS SELECT ...
situation: hive table succeed with an existed default location

This PR is going to make above two situations consist with the logic that it should throw an exception
with an existed default location.

How was this patch tested?

unit test added

@SparkQA
Copy link

SparkQA commented Mar 22, 2018

Test build #88530 has finished for PR 20886 at commit d584c9b.

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

@SparkQA
Copy link

SparkQA commented Mar 25, 2018

Test build #88564 has finished for PR 20886 at commit ff57889.

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

@SparkQA
Copy link

SparkQA commented Mar 25, 2018

Test build #88565 has finished for PR 20886 at commit 3b882fa.

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

@SparkQA
Copy link

SparkQA commented Mar 30, 2018

Test build #88742 has finished for PR 20886 at commit 95bfb7b.

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

@gengliangwang gengliangwang changed the title [WIP][SPARK-19724][SQL]create a managed table with an existed default table should throw an exception [SPARK-19724][SQL]create a managed table with an existed default table should throw an exception Mar 30, 2018
@gengliangwang
Copy link
Member Author

@gatorsmile This PR is ready for review.

@SparkQA
Copy link

SparkQA commented Mar 30, 2018

Test build #88749 has finished for PR 20886 at commit 0a35a84.

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

@gengliangwang
Copy link
Member Author

retest this please.

@SparkQA
Copy link

SparkQA commented Mar 31, 2018

Test build #88769 has finished for PR 20886 at commit 0a35a84.

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

@SparkQA
Copy link

SparkQA commented Apr 1, 2018

Test build #88796 has finished for PR 20886 at commit f1de70c.

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

Copy link
Member

Choose a reason for hiding this comment

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

Move them to DDLSuite? Change the format based on isUsingHiveMetastore?

Copy link
Member

Choose a reason for hiding this comment

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

We always check defaultTablePath ? Is that possible, the table location points to the different location?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think managed tables are always created on default path. So the check here should be correct.

Copy link
Member

Choose a reason for hiding this comment

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

CatalogTable already contains TableIdentifier . What is the reason you do not use the one directly?

@gatorsmile
Copy link
Member

This is a behavior change, we need to make it configurable and also document it in the migration guide.

@SparkQA
Copy link

SparkQA commented Apr 2, 2018

Test build #88799 has finished for PR 20886 at commit f26c08c.

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

@SparkQA
Copy link

SparkQA commented Apr 2, 2018

Test build #88807 has started for PR 20886 at commit 4d2cc31.

@gengliangwang
Copy link
Member Author

retest this please.

1 similar comment
@gengliangwang
Copy link
Member Author

retest this please.

@SparkQA
Copy link

SparkQA commented Apr 3, 2018

Test build #88846 has finished for PR 20886 at commit 13b6633.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

.createWithDefault(false)

val ALLOW_NONEMPTY_MANAGED_TABLE_LOCATION =
buildConf("spark.sql.allowNonemptyManagedTableLocation")
Copy link
Member

Choose a reason for hiding this comment

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

spark.sql.allowCreateManagedTableUsingNonemptyLocation

Also this should be an internal conf

val fs = tableLocation.getFileSystem(hadoopConf)

if (fs.exists(tableLocation) && fs.listStatus(tableLocation).nonEmpty) {
throw new AnalysisException(s"Can not create the managed table('${table.identifier}')" +
Copy link
Member

Choose a reason for hiding this comment

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

Can not -> Not allowed to

@SparkQA
Copy link

SparkQA commented Apr 4, 2018

Test build #88860 has finished for PR 20886 at commit 7a3311c.

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

@SparkQA
Copy link

SparkQA commented Apr 4, 2018

Test build #88874 has finished for PR 20886 at commit 2b2973a.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gengliangwang
Copy link
Member Author

retest this please.

@SparkQA
Copy link

SparkQA commented Apr 4, 2018

Test build #88878 has finished for PR 20886 at commit 2b2973a.

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

@gatorsmile
Copy link
Member

gatorsmile commented Apr 6, 2018

LGTM

Thanks! Merged to master

@asfgit asfgit closed this in 249007e Apr 6, 2018
robert3005 pushed a commit to palantir/spark that referenced this pull request Apr 7, 2018
…le should throw an exception

## What changes were proposed in this pull request?
This PR is to finish apache#17272

This JIRA is a follow up work after SPARK-19583

As we discussed in that PR

The following DDL for a managed table with an existed default location should throw an exception:

CREATE TABLE ... (PARTITIONED BY ...) AS SELECT ...
CREATE TABLE ... (PARTITIONED BY ...)
Currently there are some situations which are not consist with above logic:

CREATE TABLE ... (PARTITIONED BY ...) succeed with an existed default location
situation: for both hive/datasource(with HiveExternalCatalog/InMemoryCatalog)

CREATE TABLE ... (PARTITIONED BY ...) AS SELECT ...
situation: hive table succeed with an existed default location

This PR is going to make above two situations consist with the logic that it should throw an exception
with an existed default location.
## How was this patch tested?

unit test added

Author: Gengliang Wang <[email protected]>

Closes apache#20886 from gengliangwang/pr-17272.
ghost pushed a commit to dbtsai/spark that referenced this pull request Apr 10, 2018
…noreIfExists is true

## What changes were proposed in this pull request?

In the PR apache#20886, I mistakenly check the table location only when `ignoreIfExists` is false, which was following the original deprecated PR.
That was wrong. When `ignoreIfExists` is true and the target table doesn't exist, we should also check the table location. In other word, **`ignoreIfExists` has nothing to do with table location validation**.
This is a follow-up PR to fix the mistake.

## How was this patch tested?

Add one unit test.

Author: Gengliang Wang <[email protected]>

Closes apache#21001 from gengliangwang/SPARK-19724-followup.
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