[SPARK-2594][SQL] Support CACHE TABLE <name> AS SELECT ...

This feature allows user to add cache table from the select query.
Example : ```CACHE TABLE testCacheTable AS SELECT * FROM TEST_TABLE```
Spark 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.
https://github.com/apache/spark/pull/2381
https://github.com/apache/spark/pull/2390

Author : ravipesala ravindra.pesala@huawei.com

(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](https://github.com/apache/spark/pull/2382/files?diff=split#diff-5)).

To prevent duplicated code, I'd suggest to import `SQLContext._` so that we can leverage [the implicit conversion](https://github.com/apache/spark/blob/008a5ed4808d1467b47c1d6fa4d950cc6c4976b7/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala#L78-L85) from `LogicalPlan` to `SchemaRDD`, and then simply do this:

```scala
sqlContext.executePlan(plan).logical.registerTempTable(tableName)
```