Skip to content

[SPARK-19724][SQL]create a managed table with an existed default table should throw an exception - #17272

Closed
windpiger wants to merge 7 commits into
apache:masterfrom
windpiger:managedTableLocationExists
Closed

[SPARK-19724][SQL]create a managed table with an existed default table should throw an exception#17272
windpiger wants to merge 7 commits into
apache:masterfrom
windpiger:managedTableLocationExists

Conversation

@windpiger

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

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:

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

  2. 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

val db = tableDefinition.identifier.database.get
requireDbExists(db)
val table = tableDefinition.identifier.table
if (tableExists(db, table)) {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

we have check if the table exists in SessionCatalog.createtable

@SparkQA

Copy link
Copy Markdown

Test build #74436 has finished for PR 17272 at commit a0ba419.

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

assert(actual.tableType === CatalogTableType.EXTERNAL)
}

test("create table when the table already exists") {

@windpigerwindpigerMar 13, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

since in InMemoryCatalog and HiveExternalCatalog does not check if the table exists, here move the test case to SessionCatalogSuite(using InMemoryCatalog) and HiveExternalCatalogSuite

table.storage.locationUri
}

sparkSession.sessionState.catalog.checkTableOrPathExists(table, ignoreIfExists = false)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

because in following saveDataIntoTable will create the table path and store data in it, we should not check the path in following createTable, we check it here before saveDataIntoTable

@SparkQA

Copy link
Copy Markdown

Test build #74437 has finished for PR 17272 at commit 65d7ea9.

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

@SparkQA

Copy link
Copy Markdown

Test build #74441 has finished for PR 17272 at commit 0e753cc.

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

@windpiger

Copy link
Copy Markdown
ContributorAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #74445 has finished for PR 17272 at commit c8d9b77.

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

@windpiger

Copy link
Copy Markdown
ContributorAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #74468 has finished for PR 17272 at commit c8d9b77.

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

@SparkQA

Copy link
Copy Markdown

Test build #74472 has finished for PR 17272 at commit cd4a091.

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

@SparkQA

Copy link
Copy Markdown

Test build #74493 has started for PR 17272 at commit 2ac70b4.

@windpiger

Copy link
Copy Markdown
ContributorAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #74499 has finished for PR 17272 at commit 2ac70b4.

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

@windpiger
windpigerforce-pushed the managedTableLocationExists branch from 2ac70b4 to cd4a091CompareMarch 14, 2017 12:08
Comment threadpython/pyspark/sql/tests.py Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

python test failed

the location('file:/home/jenkins/workspace/SparkPullRequestBuilder/spark-warehouse/tab1') of table('`default`.`tab1`') already exists.;

the location of tab1 does not deleted , I have tried to found out in which test case it forget to delete it(search all test cases containing tab1 and run it), but they are all ok to delete the location of tab1, so here we change the table name to work around it.

@SparkQA

Copy link
Copy Markdown

Test build #74516 has finished for PR 17272 at commit 516c4e4.

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

@windpiger

Copy link
Copy Markdown
ContributorAuthor

retest this please

@SparkQA

Copy link
Copy Markdown

Test build #74524 has finished for PR 17272 at commit 516c4e4.

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

@windpiger
windpigerforce-pushed the managedTableLocationExists branch from 516c4e4 to 739f207CompareMarch 14, 2017 16:00
@SparkQA

Copy link
Copy Markdown

Test build #74535 has finished for PR 17272 at commit 739f207.

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

@SparkQA

Copy link
Copy Markdown

Test build #74604 has finished for PR 17272 at commit 4351cd7.

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

@HyukjinKwon

Copy link
Copy Markdown
Member

@windpiger is this still active?

@HyukjinKwonHyukjinKwon mentioned this pull request May 17, 2017
@gatorsmile

Copy link
Copy Markdown
Member

cc @ltnwgl Could you please take this over? Thanks!

@gatorsmile

Copy link
Copy Markdown
Member

cc @dongjoon-hyun Are you interested in this PR? Just take it over?

@gengliangwang

Copy link
Copy Markdown
Member

@gatorsmile I will take it over :)

asfgit pushed a commit that referenced this pull request Apr 6, 2018
…le should throw an exception
## 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
Author: Gengliang Wang <gengliang.wang@databricks.com>
Closes#20886 from gengliangwang/pr-17272.
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 <gengliang.wang@databricks.com>
Closesapache#20886 from gengliangwang/pr-17272.
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
## What changes were proposed in this pull request?
This PR proposes to close PRs ...
- inactive to the review comments more than a month
- WIP and inactive more than a month
- with Jenkins build failure but inactive more than a month
- suggested to be closed and no comment against that
- obviously looking inappropriate (e.g., Branch 0.5)
To make sure, I left a comment for each PR about a week ago and I could not have a response back from the author in these PRs below:
Closesapache#11129Closesapache#12085Closesapache#12162Closesapache#12419Closesapache#12420Closesapache#12491Closesapache#13762Closesapache#13837Closesapache#13851Closesapache#13881Closesapache#13891Closesapache#13959Closesapache#14091Closesapache#14481Closesapache#14547Closesapache#14557Closesapache#14686Closesapache#15594Closesapache#15652Closesapache#15850Closesapache#15914Closesapache#15918Closesapache#16285Closesapache#16389Closesapache#16652Closesapache#16743Closesapache#16893Closesapache#16975Closesapache#17001Closesapache#17088Closesapache#17119Closesapache#17272Closesapache#17971
Added:
Closesapache#17778Closesapache#17303Closesapache#17872
## How was this patch tested?
N/A
Author: hyukjinkwon <gurwls223@gmail.com>
Closesapache#18017 from HyukjinKwon/close-inactive-prs.
Sign up for freeto 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.

5 participants

@windpiger@SparkQA@HyukjinKwon@gatorsmile@gengliangwang