Uh oh!
There was an error while loading. Please reload this page.
[SPARK-2594][SQL] Support CACHE TABLE <name> AS SELECT ... - #2397
[SPARK-2594][SQL] Support CACHE TABLE <name> AS SELECT ...#2397ravipesala wants to merge 20 commits into
Conversation
This feature allows user to add cache table from the select query. Example : ADD CACHE TABLE <tableName> AS SELECT * FROM TEST_TABLE. Spark takes this type of SQL as command and it does eager caching. It can be executed from SQLContext and HiveContext. Signed-off-by: ravipesala <ravindra.pesala@huawei.com>
This feature allows user to add cache table from the select query. Example : ADD CACHE TABLE <tableName> AS SELECT * FROM TEST_TABLE. Spark takes this type of SQL as command and it does eager caching. It can be executed from SQLContext and HiveContext. Signed-off-by: ravipesala <ravindra.pesala@huawei.com>
Add-Cache-table-as
SparkQA
commented
Sep 15, 2014
Can one of the admins verify this patch? |
davies
commented
Sep 15, 2014
ok to test. |
SparkQA
commented
Sep 15, 2014
QA tests have started for PR 2397 at commit
|
SparkQA
commented
Sep 15, 2014
QA tests have finished for PR 2397 at commit
|
There was a problem hiding this comment.
We can remove as ~ if we use opt(AS ~> select) in line 186.
There was a problem hiding this comment.
Thank you for your suggestion. I have updated it as per your comment.
liancheng
commented
Sep 16, 2014
To me the only important issue here is the laziness semantics of Otherwise LGTM except for some minor issues mentioned in the comments. |
SparkQA
commented
Sep 16, 2014
QA tests have started for PR 2397 at commit
|
ravipesala
commented
Sep 16, 2014
Making lazy cache seems to be a good idea.As |
SparkQA
commented
Sep 16, 2014
QA tests have finished for PR 2397 at commit
|
marmbrus
commented
Sep 16, 2014
I agree with making it lazy. Can you also update the title and the description to reflect the final syntax? |
CACHE TABLE <name> AS SELECT ...CACHE TABLE <name> AS SELECT ...ravipesala
commented
Sep 16, 2014
Changed the behavior from eager to lazy caching. And also updated the description. |
SparkQA
commented
Sep 16, 2014
QA tests have started for PR 2397 at commit
|
SparkQA
commented
Sep 16, 2014
QA tests have finished for PR 2397 at commit
|
There was a problem hiding this comment.
(Probably my final comment on this PR :) )
As described in PR #2382, we shouldn't store analyzed logical plan when registering tables any more (see here).
To prevent duplicated code, I'd suggest to import SQLContext._ so that we can leverage the implicit conversion from LogicalPlan to SchemaRDD, and then simply do this:
sqlContext.executePlan(plan).logical.registerTempTable(tableName)There was a problem hiding this comment.
Thank you for your comment. It is a good idea to import sqlContext._. But we can simplify as below code if we import it. Please comment on it.
import sqlContext._
plan.registerTempTable(tableName)
cacheTable(tableName) There was a problem hiding this comment.
Ah, yes you're right, we can use plan directly. And instead of importing sqlContext._, I'd import SQLContext._ in the import section at the begin of this file:
import org.apache.spark.sql.SQLContext._
There was a problem hiding this comment.
It seems we cannot use the import org.apache.spark.sql.SQLContext._ at the beginning of file to use implicit. Because there is no object defined for SQLContext and implicits are only part of class SQLContext. We can only use the import on instance like import sqlContext._ Please correct me if I am wrong.
There was a problem hiding this comment.
Sorry again, you're right, I mistook sqlContext._ for SparkContext._...
There was a problem hiding this comment.
Updated the code. Please review
liancheng
commented
Sep 17, 2014
LGTM except for the analyzed logical plan issue as mentioned in my last comment. Thanks for working on this! |
SparkQA
commented
Sep 18, 2014
QA tests have started for PR 2397 at commit
|
ravipesala
commented
Sep 18, 2014
Updated as per comments. Please review. |
SparkQA
commented
Sep 18, 2014
QA tests have finished for PR 2397 at commit
|
liancheng
commented
Sep 18, 2014
@ravipesala Thanks for working on this! @marmbrus I think this is ready to go :) |
marmbrus
commented
Sep 19, 2014
Thanks! I've merged this to master. |
This feature allows user to add cache table from the select query.
Example :
CACHE TABLE testCacheTable AS SELECT * FROM TEST_TABLESpark takes this type of SQL as command and it does lazy caching just like
SQLContext.cacheTable,CACHE TABLE <name>does.It can be executed from both SQLContext and HiveContext.
Recreated the pull request after rebasing with master.And fixed all the comments raised in previous pull requests.
#2381
#2390
Author : ravipesala ravindra.pesala@huawei.com