Skip to content

[SPARK-3907][sql] add truncate table support - #2770

Closed
wangxiaojing wants to merge 7 commits into
apache:masterfrom
wangxiaojing:spark-3907
Closed

wangxiaojing wants to merge 7 commits into
apache:masterfrom
wangxiaojing:spark-3907

Conversation

@wangxiaojing

Copy link
Copy Markdown
Contributor

JIRA issue: [SPARK-3907]https://issues.apache.org/jira/browse/SPARK-3907

Add turncate table support
TRUNCATE TABLE table_name [PARTITION partition_spec];
partition_spec:
: (partition_col = partition_col_value, partition_col = partiton_col_value, ...)
Removes all rows from a table or partition(s). Currently target table should be native/managed table or exception will be thrown. User can specify partial partition_spec for truncating multiple partitions at once and omitting partition_spec will truncate all partitions in the table.

@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

1 similar comment
@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@rxin

rxin commented Oct 12, 2014

Copy link
Copy Markdown
Contributor

Jenkins, test this please.

@SparkQA

SparkQA commented Oct 12, 2014

Copy link
Copy Markdown

QA tests have started for PR 2770 at commit e483547.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 12, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2770 at commit e483547.

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

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/21673/
Test FAILed.

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.

“tabel” is a typo. I think it's better not to include this part here, which would make the code not very clean. You can remove this part and fix truncate column in another PR, or fix that in this PR.

@SparkQA

SparkQA commented Oct 16, 2014

Copy link
Copy Markdown

QA tests have started for PR 2770 at commit e483547.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 16, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2770 at commit e483547.

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

@wangxiaojing

Copy link
Copy Markdown
Contributor Author

@rxin

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.

why is truncate table a no-explain-command?

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.

@adrian-wang I think explain for truncate table is meaningless.

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.

I think we should add that in nativeCommands

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.

If add truncate table in nativeCommands,the sql truncate table test columns(i) will run hive mapreduce.At present, the columns way only support rcfile in hive.so ,we must put truncate table in nodeToPlan,and truncate table name columns(i)return anomalies.

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 you add a comment below explaining this?

@SparkQA

SparkQA commented Oct 20, 2014

Copy link
Copy Markdown

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 20, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2770 at commit f6e710e.

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

@liancheng

Copy link
Copy Markdown
Contributor

test this please

@SparkQA

SparkQA commented Oct 24, 2014

Copy link
Copy Markdown

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 24, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2770 at commit f6e710e.

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

@AmplabJenkins

Copy link
Copy Markdown

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22102/
Test FAILed.

@liancheng

Copy link
Copy Markdown
Contributor

retest this please

@SparkQA

SparkQA commented Oct 24, 2014

Copy link
Copy Markdown

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 24, 2014

Copy link
Copy Markdown

QA tests have finished for PR 2770 at commit f6e710e.

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

@AmplabJenkins

Copy link
Copy Markdown

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22104/
Test PASSed.

@SparkQA

SparkQA commented Oct 25, 2014

Copy link
Copy Markdown

Test build #442 has started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 25, 2014

Copy link
Copy Markdown

Test build #442 has finished for PR 2770 at commit f6e710e.

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

@SparkQA

SparkQA commented Oct 26, 2014

Copy link
Copy Markdown

Test build #468 has started for PR 2770 at commit 7a03707.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 26, 2014

Copy link
Copy Markdown

Test build #468 has finished for PR 2770 at commit 7a03707.

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

@SparkQA

SparkQA commented Oct 26, 2014

Copy link
Copy Markdown

Test build #470 has started for PR 2770 at commit 7a03707.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 26, 2014

Copy link
Copy Markdown

Test build #470 has finished for PR 2770 at commit 7a03707.

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

@marmbrus

Copy link
Copy Markdown
Contributor

It appears there are some style violations:

[marmbrus@michaels-mbp spark (pr/2770)]$ sbt hive/scalastyle
[info] Set current project to spark-parent (in build file:/Users/marmbrus/workspace/spark/)
error file=/Users/marmbrus/workspace/spark/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala message=File line length exceeds 100 characters line=477
error file=/Users/marmbrus/workspace/spark/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala message=insert.a.single.space.after.comment.start.and.before.end.message line=125 column=4
error file=/Users/marmbrus/workspace/spark/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala message=insert.a.single.space.after.comment.start.and.before.end.message line=477 column=4

@marmbrus

Copy link
Copy Markdown
Contributor

ok to test

@marmbrus

Copy link
Copy Markdown
Contributor

Can you please make the title SPARK-XXXX so that the merge script recognizes the JIRA?

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #22331 has started for PR 2770 at commit 63dbd81.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Oct 28, 2014

Copy link
Copy Markdown

Test build #22331 has finished for PR 2770 at commit 63dbd81.

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

@AmplabJenkins

Copy link
Copy Markdown

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22331/
Test PASSed.

@wangxiaojing wangxiaojing changed the title [spark-3907][sql] add truncate table support [SPARK-3907][sql] add truncate table support Oct 28, 2014
@marmbrus

Copy link
Copy Markdown
Contributor

Thanks! Merged to master.

@asfgit asfgit closed this in 0c34fa5 Oct 28, 2014
@OopsOutOfMemory

Copy link
Copy Markdown
Contributor

@wangxiaojing @tianyi @marmbrus
Hi, wangxiaojing, I have an issues for this PR.
Currently the truncate table works fine in the situation that current table is in the corresponding database session. But it doesn't work in the scenario which the table is not in the corresponding database session.
What I mean is :
Assume we have two database:default, dw. A table named test_table in database dw
By default we login as default database session. So I run:

use dw;
truncate table test_table [partions......];  is OK.

If I just use the default database default to run:

use default;
truncate table dw.test_table;

It will throw exception

Failed to parse: truncate table dw.test_table.
 line 1:17 missing EOF at '.' near 'dw'

It's a bug when parsing the truncate table xxx
It would be nicer to fix it : )

@marmbrus

marmbrus commented Nov 4, 2014

Copy link
Copy Markdown
Contributor

@OopsOutOfMemory please file a JIRA.

@wangxiaojing

Copy link
Copy Markdown
Contributor Author

@OopsOutOfMemory Thanks a lot!
This bug is also found in the hive.
eg: TRUNCATE TABLE default.test;
FAILED: ParseException line 1:22 missing EOF at '.' near 'default'

@OopsOutOfMemory

Copy link
Copy Markdown
Contributor

Yep, that is what I guess yesterday.
I think we should support all the commands which are similar to this.
The JIRA for this one locate in below:
https://issues.apache.org/jira/browse/SPARK-4232 .

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.

9 participants