aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/sql/readwriter.py
diff options
context:
space:
mode:
authorMechCoder <manojkumarsivaraj334@gmail.com>2015-08-14 12:46:05 -0700
committerXiangrui Meng <meng@databricks.com>2015-08-14 12:46:05 -0700
commitffa05c84fe75663fc33f3d954d1cb1e084ab3280 (patch)
treeeb5599d7c52bf7ddcd72d340952bca83e169c2d0 /python/pyspark/sql/readwriter.py
parentece00566e4d5f38585f2810bef38e526cae7d25e (diff)
downloadspark-ffa05c84fe75663fc33f3d954d1cb1e084ab3280.tar.gz
spark-ffa05c84fe75663fc33f3d954d1cb1e084ab3280.tar.bz2
spark-ffa05c84fe75663fc33f3d954d1cb1e084ab3280.zip
[SPARK-9828] [PYSPARK] Mutable values should not be default arguments
Author: MechCoder <manojkumarsivaraj334@gmail.com> Closes #8110 from MechCoder/spark-9828.
Diffstat (limited to 'python/pyspark/sql/readwriter.py')
-rw-r--r--python/pyspark/sql/readwriter.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/pyspark/sql/readwriter.py b/python/pyspark/sql/readwriter.py
index bf6ac084bb..78247c8fa7 100644
--- a/python/pyspark/sql/readwriter.py
+++ b/python/pyspark/sql/readwriter.py
@@ -182,7 +182,7 @@ class DataFrameReader(object):
@since(1.4)
def jdbc(self, url, table, column=None, lowerBound=None, upperBound=None, numPartitions=None,
- predicates=None, properties={}):
+ predicates=None, properties=None):
"""
Construct a :class:`DataFrame` representing the database table accessible
via JDBC URL `url` named `table` and connection `properties`.
@@ -208,6 +208,8 @@ class DataFrameReader(object):
should be included.
:return: a DataFrame
"""
+ if properties is None:
+ properties = dict()
jprop = JavaClass("java.util.Properties", self._sqlContext._sc._gateway._gateway_client)()
for k in properties:
jprop.setProperty(k, properties[k])
@@ -427,7 +429,7 @@ class DataFrameWriter(object):
self._jwrite.orc(path)
@since(1.4)
- def jdbc(self, url, table, mode=None, properties={}):
+ def jdbc(self, url, table, mode=None, properties=None):
"""Saves the content of the :class:`DataFrame` to a external database table via JDBC.
.. note:: Don't create too many partitions in parallel on a large cluster;\
@@ -445,6 +447,8 @@ class DataFrameWriter(object):
arbitrary string tag/value. Normally at least a
"user" and "password" property should be included.
"""
+ if properties is None:
+ properties = dict()
jprop = JavaClass("java.util.Properties", self._sqlContext._sc._gateway._gateway_client)()
for k in properties:
jprop.setProperty(k, properties[k])