You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2016/09/18 06:35:43 UTC
[GitHub] spark pull request #15136: [SPARK-17581] [SQL] Invalidate Statistics After S...
GitHub user gatorsmile opened a pull request:
https://github.com/apache/spark/pull/15136
[SPARK-17581] [SQL] Invalidate Statistics After Some ALTER TABLE Commands
### What changes were proposed in this pull request?
In the recent statistics-related work, our focus is on how to generate and store the statistics. After `Analyze Table` commands, the statistics will not be changed unless users run the command again. However, Hive behaves differently. For example, `ALTER TABLE SET LOCATION` will invalidate the statistics, including `numRows` and `rawDataSize`.
```
hive> describe formatted t2;
...
Location: hdfs://6b68a24121f4:9000/user/hive/warehouse/t2
Table Type: MANAGED_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE true
numFiles 4
numRows 2
rawDataSize 2
totalSize 4
transient_lastDdlTime 1464590855
...
```
```
hive> alter table t2 set location 'hdfs://6b68a24121f4:9000/user/hive/warehouse/t1';
OK
Time taken: 0.113 seconds
```
```
hive> describe formatted t2;
...
Location: hdfs://6b68a24121f4:9000/user/hive/warehouse/t1
Table Type: MANAGED_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
last_modified_by root
last_modified_time 1474178025
numFiles 4
numRows -1
rawDataSize -1
totalSize 4
...
```
This PR tries to fix the related issues.
### How was this patch tested?
Added test cases.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/gatorsmile/spark invalidateStatsAfterAlterTable
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15136.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #15136
----
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15136: [SPARK-17581] [SQL] Invalidate Statistics After S...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile closed the pull request at:
https://github.com/apache/spark/pull/15136
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:
https://github.com/apache/spark/pull/15136
is `SET LOCATION` the only command that can invalidate the statistics?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15136
**[Test build #65554 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65554/consoleFull)** for PR 15136 at commit [`54df392`](https://github.com/apache/spark/commit/54df39243eca2eed0482ce37f842b3ccfbc77723).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:
https://github.com/apache/spark/pull/15136
Will do more investigation on this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15136
**[Test build #65554 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65554/consoleFull)** for PR 15136 at commit [`54df392`](https://github.com/apache/spark/commit/54df39243eca2eed0482ce37f842b3ccfbc77723).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:
https://github.com/apache/spark/pull/15136
@hvanhovell @cloud-fan Do you think automatic invalidation makes sense after some ALTER TABLE commands?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:
https://github.com/apache/spark/pull/15136
The behavior of Hive 2.1 is different from Hive 1.6. Hive 2.1 does not invalidate the stats, but only mark it inaccurate. Thus, this PR can be closed. Thanks!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:
https://github.com/apache/spark/pull/15136
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/65554/
Test PASSed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15136: [SPARK-17581] [SQL] Invalidate Statistics After Some ALT...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:
https://github.com/apache/spark/pull/15136
Merged build finished. Test PASSed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15136: [SPARK-17581] [SQL] Invalidate Statistics After S...
Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/15136#discussion_r79298630
--- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala ---
@@ -290,6 +290,27 @@ class StatisticsSuite extends QueryTest with TestHiveSingleton with SQLTestUtils
}
}
+ test("alter table set location after analyze table") {
+ val textTable = "textTable"
+ withTable(textTable) {
+ sql(s"CREATE TABLE $textTable (key STRING, value STRING) STORED AS TEXTFILE")
+ sql(s"INSERT INTO TABLE $textTable SELECT * FROM src")
+ sql(s"ANALYZE TABLE $textTable COMPUTE STATISTICS")
+ checkStats(
+ textTable, isDataSourceTable = false, hasSizeInBytes = true, expectedRowCounts = Some(500))
+
+ withTempDir { tmpDir =>
+ val path = tmpDir.getCanonicalPath
+ sql(s"ALTER TABLE $textTable SET LOCATION '$path'")
+ checkStats(
+ textTable,
+ isDataSourceTable = false,
+ hasSizeInBytes = false,
--- End diff --
After the PR: https://github.com/apache/spark/pull/14971, we can reuse the Hive-generated statistics. Thus, this value will be `true`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org