Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/12784#discussion_r61645639
--- Diff: python/pyspark/sql/tests.py ---
@@ -1394,6 +1395,200 @@ def test_toDF_with_schema_string(self):
self.assertEqual(df.schema.simpleString(), "struct<value:int>")
self.assertEqual(df.collect(), [Row(key=i) for i in range(100)])
+ def test_conf(self):
+ spark = self.sparkSession
+ spark.setConf("bogo", "sipeo")
+ self.assertEqual(self.sparkSession.conf.get("bogo"), "sipeo")
+ spark.setConf("bogo", "ta")
+ self.assertEqual(spark.conf.get("bogo"), "ta")
+ self.assertEqual(spark.conf.get("bogo", "not.read"), "ta")
+ self.assertEqual(spark.conf.get("not.set", "ta"), "ta")
+ self.assertRaisesRegexp(Exception, "not.set", lambda:
spark.conf.get("not.set"))
+ spark.conf.unset("bogo")
+ self.assertEqual(spark.conf.get("bogo", "colombia"), "colombia")
+
+ def test_current_database(self):
+ spark = self.sparkSession
+ spark.catalog._reset()
+ self.assertEquals(spark.catalog.currentDatabase(), "default")
+ spark.sql("CREATE DATABASE some_db")
+ spark.catalog.setCurrentDatabase("some_db")
+ self.assertEquals(spark.catalog.currentDatabase(), "some_db")
+ self.assertRaisesRegexp(
+ AnalysisException,
+ "does_not_exist",
+ lambda: spark.catalog.setCurrentDatabase("does_not_exist"))
+
+ def test_list_databases(self):
+ spark = self.sparkSession
+ spark.catalog._reset()
+ databases = [db.name for db in spark.catalog.listDatabases()]
+ self.assertEquals(databases, ["default"])
+ spark.sql("CREATE DATABASE some_db")
+ databases = [db.name for db in spark.catalog.listDatabases()]
+ self.assertEquals(sorted(databases), ["default", "some_db"])
+
+ def test_list_tables(self):
+ from catalog import Table
--- End diff --
It's better to use full path
from pyspark.sql.catalog import Table
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]