code: def _create_shell_session():
          
          import py4j
          from pyspark.conf import SparkConf
          from pyspark.context import SparkContext
          try:
              # Try to access HiveConf, it will raise exception if Hive is not added
              conf = SparkConf()
              if conf.get('spark.sql.catalogImplementation', 'hive').lower() == 'hive':
                  SparkContext._jvm.org.apache.hadoop.hive.conf.HiveConf()
                  return SparkSession.builder\
                      .enableHiveSupport()\
                      .getOrCreate()
              else:
                  return SparkSession.builder.getOrCreate()
          except (py4j.protocol.Py4JError, TypeError):
              if conf.get('spark.sql.catalogImplementation', '').lower() == 'hive':
                  warnings.warn("Fall back to non-hive support because failing to access HiveConf, "
                                "please make sure you build spark with hive")
  
          return SparkSession.builder.getOrCreate()
docs: Initialize a SparkSession for a pyspark shell session. This is called from shell.py
          to make error handling simpler without needing to declare local variables in that
          script, which would expose those to users.