Spark 4103

Currently the sessionState in HiveContext is lazy evaluated, and to start the session, SessionState.start() has to be invoked to initialize it. Using ThreadLocal variable natively in hive to track the availability of SessionState and initialize it if required. It avoid multiple thread sharing the same SessionState or single thread invoke SessionState.start with the same SessionState multiple times, which seems to cause unexpected behavior, and break the contract defined in hive. Refer below comments form SessionState in hive.

  /**
   * set current session to existing session object if a thread is running
   * multiple sessions - it must call this method with the new session object
   * when switching from one session to another.
   * @throws HiveException
   */
 public static SessionState start(SessionState startSs) {
  ...
 }