[SPARK-4103][SQL] Clean up SessionState in HiveContext by using ThreadLocal varaible in Hive

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) {
  ...
 }
Several comments here:

1. `HiveContext.hiveconf` should be retrieved from the current `SessionState` if `SessionState.get()` is non-null. That's why `hiveconf` and `sessionState` are always initialized together in [#2887](https://github.com/apache/spark/pull/2887/files#diff-ff50aea397a607b79df9bec6f2a841dbR233)
1. IO redirection and Hive properties propagation also need to be performed when `SessionState.get()` returns a non-null `SessionState` started elsewhere. This is required by Spark SQL CLI since `SparkSQLCLIDriver` creates a `CliSessionState` before `HiveContext` initialization.
1. I guess you're trying to make `HiveContext` play well with multi-session scenarios by introducing `getSessionState()` here? I had also considered this issue earlier, but unfortunately IMO proper multiple Hive session support may require major refactoring over `HiveContext` (e.g. make it absolutely thread safe). Also, Spark SQL Hive support will probably be reimplemented against the up coming foreign data source API. So I'd rather defer this major task later.

(As a globally used thread local object, Hive `SessionState` is really annoying...)