GitHub user dongjoon-hyun opened a pull request:
https://github.com/apache/spark/pull/18530
[SPARK-20256][SQL][BRANCH-2.1] SessionState should be created more lazily
## What changes were proposed in this pull request?
`SessionState` is designed to be created lazily. However, in reality, it
created immediately in `SparkSession.Builder.getOrCreate`
([here](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala#L943)).
This PR aims to recover the lazy behavior by keeping the options into
`initialSessionOptions`. The benefit is like the following. Users can start
`spark-shell` and use RDD operations without any problems.
**BEFORE**
```scala
$ bin/spark-shell
java.lang.IllegalArgumentException: Error while instantiating
'org.apache.spark.sql.hive.HiveSessionStateBuilder'
...
Caused by: org.apache.spark.sql.AnalysisException:
org.apache.hadoop.hive.ql.metadata.HiveException:
MetaException(message:java.security.AccessControlException:
Permission denied: user=spark, access=READ,
inode="/apps/hive/warehouse":hive:hdfs:drwx------
```
As reported in SPARK-20256, this happens when the warehouse directory is
not allowed for this user.
**AFTER**
```scala
$ bin/spark-shell
...
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 2.1.2-SNAPSHOT
/_/
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java
1.8.0_131)
Type in expressions to have them evaluated.
Type :help for more information.
scala> sc.range(0, 10, 1).count()
res0: Long = 10
```
## How was this patch tested?
Manual.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dongjoon-hyun/spark SPARK-20256-BRANCH-2.1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/18530.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 #18530
----
commit 4843350ecfd358e6cb8c649bd0dad3970e470955
Author: Dongjoon Hyun <[email protected]>
Date: 2017-07-04T17:30:08Z
[SPARK-20256][SQL] SessionState should be created more lazily
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]