Skip to content

[SPARK-29643][SQL] ALTER TABLE/VIEW (DROP PARTITION) should look up catalog/table like v2 commands#26303

Closed
huaxingao wants to merge 5 commits into
apache:masterfrom
huaxingao:spark-29643
Closed

[SPARK-29643][SQL] ALTER TABLE/VIEW (DROP PARTITION) should look up catalog/table like v2 commands#26303
huaxingao wants to merge 5 commits into
apache:masterfrom
huaxingao:spark-29643

Conversation

@huaxingao

@huaxingao huaxingao commented Oct 30, 2019

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add AlterTableDropPartitionStatement and make ALTER TABLE/VIEW ... DROP PARTITION go through the same catalog/table resolution framework of v2 commands.

Why are the changes needed?

It's important to make all the commands have the same table resolution behavior, to avoid confusing end-users. e.g.

USE my_catalog
DESC t // success and describe the table t from my_catalog
ALTER TABLE t DROP PARTITION (id=1)  // report table not found as there is no table t in the session catalog

Does this PR introduce any user-facing change?

Yes. When running ALTER TABLE/VIEW ... DROP PARTITION, Spark fails the command if the current catalog is set to a v2 catalog, or the table name specified a v2 catalog.

How was this patch tested?

Unit tests.

@SparkQA

SparkQA commented Oct 30, 2019

Copy link
Copy Markdown

Test build #112880 has finished for PR 26303 at commit ea3c66c.

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

@huaxingao

Copy link
Copy Markdown
Contributor Author

@viirya @imback82 Could you please review? Do I need to follow the implementation in #26304?

@imback82

Copy link
Copy Markdown
Contributor

This command doesn't need to follow #26041.

+@cloud-fan

| ALTER TABLE tableIdentifier
| ALTER TABLE multipartIdentifier
DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions
| ALTER VIEW tableIdentifier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since view is not supported, can we just combine this with table as (TABLE | VIEW)? @cloud-fan can confirm.

@cloud-fan cloud-fan Oct 30, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we check if the feature sets are the same between table and view? I know some ALTER TABLE commands have a view version in the parser, but not sure if it applies to all ALTER TABLE commands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there are only a few ALTER VIEW parser rules, let's keep them separated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ALTER TABLE ... DROP PARTITION has an optional PURGE in the end, but ALTER TABLE doesn't. I guess keep them separated? They use the same parser rule, though.

| ALTER TABLE tableIdentifier
from=partitionSpec RENAME TO to=partitionSpec #renameTablePartition
| ALTER TABLE tableIdentifier
| ALTER TABLE multipartIdentifier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: one space not two

| ALTER TABLE multipartIdentifier
DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE? #dropTablePartitions
| ALTER VIEW tableIdentifier
DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* #dropTablePartitions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I missed it. These 2 parser rules share the same label, so they are essentially one rule.
I agree with @imback82 that it's better to merge them:

ALTER TABLE | VIEW multipartIdentifier
  DROP (IF EXISTS)? partitionSpec (',' partitionSpec)* PURGE?

@viirya

viirya commented Oct 31, 2019

Copy link
Copy Markdown
Member

Please also update the PR title (adding VIEW).

@huaxingao huaxingao changed the title [SPARK-29643][SQL] ALTER TABLE (DROP PARTITION) should look up catalog/table like v2 commands [SPARK-29643][SQL] ALTER TABLE/VIEW (DROP PARTITION) should look up catalog/table like v2 commands Oct 31, 2019
@SparkQA

SparkQA commented Oct 31, 2019

Copy link
Copy Markdown

Test build #112992 has finished for PR 26303 at commit 12a8ad6.

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

@cloud-fan

Copy link
Copy Markdown
Contributor

retest this please

@SparkQA

SparkQA commented Oct 31, 2019

Copy link
Copy Markdown

Test build #113004 has finished for PR 26303 at commit 12a8ad6.

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

@cloud-fan

Copy link
Copy Markdown
Contributor

retest this please

@SparkQA

SparkQA commented Oct 31, 2019

Copy link
Copy Markdown

Test build #113026 has finished for PR 26303 at commit 12a8ad6.

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

@huaxingao

Copy link
Copy Markdown
Contributor Author

retest this please

@viirya

viirya commented Oct 31, 2019

Copy link
Copy Markdown
Member

retest this please.

@SparkQA

SparkQA commented Oct 31, 2019

Copy link
Copy Markdown

Test build #113040 has finished for PR 26303 at commit 12a8ad6.

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

@SparkQA

SparkQA commented Nov 1, 2019

Copy link
Copy Markdown

Test build #113049 has finished for PR 26303 at commit faa2361.

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

@SparkQA

SparkQA commented Nov 1, 2019

Copy link
Copy Markdown

Test build #113076 has finished for PR 26303 at commit 07dbe47.

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

@cloud-fan cloud-fan closed this in 14337f6 Nov 1, 2019
@cloud-fan

Copy link
Copy Markdown
Contributor

thanks, merging to master!

@huaxingao

Copy link
Copy Markdown
Contributor Author

Thanks! @cloud-fan @viirya @imback82

@huaxingao huaxingao deleted the spark-29643 branch November 1, 2019 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants