diff options
Diffstat (limited to 'python/pyspark/sql/readwriter.py')
-rw-r--r-- | python/pyspark/sql/readwriter.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/pyspark/sql/readwriter.py b/python/pyspark/sql/readwriter.py index 6c809d1139..e39cf1ae03 100644 --- a/python/pyspark/sql/readwriter.py +++ b/python/pyspark/sql/readwriter.py @@ -33,10 +33,13 @@ __all__ = ["DataFrameReader", "DataFrameWriter"] def to_str(value): """ - A wrapper over str(), but convert bool values to lower case string + A wrapper over str(), but converts bool values to lower case strings. + If None is given, just returns None, instead of converting it to string "None". """ if isinstance(value, bool): return str(value).lower() + elif value is None: + return value else: return str(value) @@ -398,7 +401,7 @@ class DataFrameWriter(object): def option(self, key, value): """Adds an output option for the underlying data source. """ - self._jwrite = self._jwrite.option(key, value) + self._jwrite = self._jwrite.option(key, to_str(value)) return self @since(1.4) @@ -406,7 +409,7 @@ class DataFrameWriter(object): """Adds output options for the underlying data source. """ for k in options: - self._jwrite = self._jwrite.option(k, options[k]) + self._jwrite = self._jwrite.option(k, to_str(options[k])) return self @since(1.4) |