code: def test_save_and_load_table(self):
      df = self.df
      tmpPath = tempfile.mkdtemp()
      shutil.rmtree(tmpPath)
      df.write.saveAsTable(
          "savedJsonTable", "json", "append", path=tmpPath
      )
      actual = self.spark.catalog.createTable(
          "externalJsonTable", tmpPath, "json"
      )
      self.assertEqual(
          sorted(df.collect()),
          sorted(
              self.spark.sql("SELECT * FROM savedJsonTable").collect()
          ),
      )
      self.assertEqual(
          sorted(df.collect()),
          sorted(
              self.spark.sql(
                  "SELECT * FROM externalJsonTable"
              ).collect()
          ),
      )
      self.assertEqual(sorted(df.collect()), sorted(actual.collect()))
      self.spark.sql("DROP TABLE externalJsonTable")
  
      df.write.saveAsTable(
          "savedJsonTable", "json", "overwrite", path=tmpPath
      )
      schema = StructType([StructField("value", StringType(), True)])
      actual = self.spark.catalog.createTable(
          "externalJsonTable",
          source="json",
          schema=schema,
          path=tmpPath,
          noUse="this options will not be used",
      )
      self.assertEqual(
          sorted(df.collect()),
          sorted(
              self.spark.sql("SELECT * FROM savedJsonTable").collect()
          ),
      )
      self.assertEqual(
          sorted(df.select("value").collect()),
          sorted(
              self.spark.sql(
                  "SELECT * FROM externalJsonTable"
              ).collect()
          ),
      )
      self.assertEqual(
          sorted(df.select("value").collect()), sorted(actual.collect())
      )
      self.spark.sql("DROP TABLE savedJsonTable")
      self.spark.sql("DROP TABLE externalJsonTable")
  
      defaultDataSourceName = self.spark.conf.get(
          "spark.sql.sources.default", "org.apache.spark.sql.parquet"
      )
      self.spark.sql(
          "SET spark.sql.sources.default=org.apache.spark.sql.json"
      )
      df.write.saveAsTable(
          "savedJsonTable", path=tmpPath, mode="overwrite"
      )
      actual = self.spark.catalog.createTable(
          "externalJsonTable", path=tmpPath
      )
      self.assertEqual(
          sorted(df.collect()),
          sorted(
              self.spark.sql("SELECT * FROM savedJsonTable").collect()
          ),
      )
      self.assertEqual(
          sorted(df.collect()),
          sorted(
              self.spark.sql(
                  "SELECT * FROM externalJsonTable"
              ).collect()
          ),
      )
      self.assertEqual(sorted(df.collect()), sorted(actual.collect()))
      self.spark.sql("DROP TABLE savedJsonTable")
      self.spark.sql("DROP TABLE externalJsonTable")
      self.spark.sql(
          "SET spark.sql.sources.default=" + defaultDataSourceName
      )
  
      shutil.rmtree(tmpPath)
  
imports: import os
  import shutil
  import sys
  import tempfile
  import unittest
  from importlib import reload
  import py4j
  from pyspark import SparkContext, SQLContext
  from pyspark.sql import Row, SparkSession
  from pyspark.sql.types import StructType, StringType, StructField
  from pyspark.testing.utils import ReusedPySparkTestCase
label_desc: Use image node_id 4 for calling the HiveContextSQLTests obj's underlying member method code with example usage: obj.test_save_and_load_table() without return types