Back to home page

OSCL-LXR

 
 

    


0001 #
0002 # Licensed to the Apache Software Foundation (ASF) under one or more
0003 # contributor license agreements.  See the NOTICE file distributed with
0004 # this work for additional information regarding copyright ownership.
0005 # The ASF licenses this file to You under the Apache License, Version 2.0
0006 # (the "License"); you may not use this file except in compliance with
0007 # the License.  You may obtain a copy of the License at
0008 #
0009 #    http://www.apache.org/licenses/LICENSE-2.0
0010 #
0011 # Unless required by applicable law or agreed to in writing, software
0012 # distributed under the License is distributed on an "AS IS" BASIS,
0013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 # See the License for the specific language governing permissions and
0015 # limitations under the License.
0016 #
0017 
0018 from pyspark.testing.sqlutils import ReusedSQLTestCase
0019 
0020 
0021 class ConfTests(ReusedSQLTestCase):
0022 
0023     def test_conf(self):
0024         spark = self.spark
0025         spark.conf.set("bogo", "sipeo")
0026         self.assertEqual(spark.conf.get("bogo"), "sipeo")
0027         spark.conf.set("bogo", "ta")
0028         self.assertEqual(spark.conf.get("bogo"), "ta")
0029         self.assertEqual(spark.conf.get("bogo", "not.read"), "ta")
0030         self.assertEqual(spark.conf.get("not.set", "ta"), "ta")
0031         self.assertRaisesRegexp(Exception, "not.set", lambda: spark.conf.get("not.set"))
0032         spark.conf.unset("bogo")
0033         self.assertEqual(spark.conf.get("bogo", "colombia"), "colombia")
0034 
0035         self.assertEqual(spark.conf.get("hyukjin", None), None)
0036 
0037         # This returns 'STATIC' because it's the default value of
0038         # 'spark.sql.sources.partitionOverwriteMode', and `defaultValue` in
0039         # `spark.conf.get` is unset.
0040         self.assertEqual(spark.conf.get("spark.sql.sources.partitionOverwriteMode"), "STATIC")
0041 
0042         # This returns None because 'spark.sql.sources.partitionOverwriteMode' is unset, but
0043         # `defaultValue` in `spark.conf.get` is set to None.
0044         self.assertEqual(spark.conf.get("spark.sql.sources.partitionOverwriteMode", None), None)
0045 
0046 
0047 if __name__ == "__main__":
0048     import unittest
0049     from pyspark.sql.tests.test_conf import *
0050 
0051     try:
0052         import xmlrunner
0053         testRunner = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=2)
0054     except ImportError:
0055         testRunner = None
0056     unittest.main(testRunner=testRunner, verbosity=2)