text: from os.path import abspath
  
  from pyspark.sql import SparkSession
  from pyspark.sql import Row
  
  # warehouse_location points to the default location for managed databases and tables
  warehouse_location = abspath('spark-warehouse')
  
  spark = SparkSession \
      .builder \
      .appName("Python Spark SQL Hive integration example") \
      .config("spark.sql.warehouse.dir", warehouse_location) \
      .enableHiveSupport() \
      .getOrCreate()
  
  # spark is an existing SparkSession
  spark.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING) USING hive")
  spark.sql("LOAD DATA LOCAL INPATH 'kv1.txt' INTO TABLE src")
  
  # Queries are expressed in HiveQL
  spark.sql("SELECT * FROM src").show()
  # +---+-------+
  # |key|  value|
  # +---+-------+
  # |238|val_238|
  # | 86| val_86|
  # |311|val_311|
  # ...
  
  # Aggregation queries are also supported.
  spark.sql("SELECT COUNT(*) FROM src").show()
  # +--------+
  # |count(1)|
  # +--------+
  # |    500 |
  # +--------+
  