Skip to content

Conversation

@wangxiaojing
Copy link
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

Can one of the admins verify this patch?

1 similar comment
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@rxin
Copy link
Contributor

rxin commented Oct 12, 2014

Jenkins, test this please.

@SparkQA
Copy link

SparkQA commented Oct 12, 2014

QA tests have started for PR 2770 at commit e483547.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 12, 2014

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

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
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
Copy link

SparkQA commented Oct 16, 2014

QA tests have started for PR 2770 at commit e483547.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 16, 2014

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
Contributor Author

@rxin

Copy link
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
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
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
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
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
Copy link

SparkQA commented Oct 20, 2014

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 20, 2014

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
Contributor

test this please

@SparkQA
Copy link

SparkQA commented Oct 24, 2014

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 24, 2014

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

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
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Oct 24, 2014

QA tests have started for PR 2770 at commit f6e710e.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 24, 2014

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

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
Copy link

SparkQA commented Oct 25, 2014

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

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 25, 2014

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
Copy link

SparkQA commented Oct 26, 2014

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

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 26, 2014

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
Copy link

SparkQA commented Oct 26, 2014

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

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 26, 2014

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
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
Contributor

ok to test

@marmbrus
Copy link
Contributor

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

@SparkQA
Copy link

SparkQA commented Oct 28, 2014

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

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Oct 28, 2014

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

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
Contributor

Thanks! Merged to master.

@asfgit asfgit closed this in 0c34fa5 Oct 28, 2014
@OopsOutOfMemory
Copy link
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
Copy link
Contributor

marmbrus commented Nov 4, 2014

@OopsOutOfMemory please file a JIRA.

@wangxiaojing
Copy link
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
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