Skip to content

Commit ac2e17b

Browse files
Cheolsoo Parkrxin
authored andcommitted
[SPARK-8355] [SQL] Python DataFrameReader/Writer should mirror Scala
I compared PySpark DataFrameReader/Writer against Scala ones. `Option` function is missing in both reader and writer, but the rest seems to all match. I added `Option` to reader and writer and updated the `pyspark-sql` test. Author: Cheolsoo Park <[email protected]> Closes apache#7078 from piaozhexiu/SPARK-8355 and squashes the following commits: c63d419 [Cheolsoo Park] Fix version 524e0aa [Cheolsoo Park] Add option function to df reader and writer
1 parent 0b10662 commit ac2e17b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

python/pyspark/sql/readwriter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ def schema(self, schema):
7373
self._jreader = self._jreader.schema(jschema)
7474
return self
7575

76+
@since(1.5)
77+
def option(self, key, value):
78+
"""Adds an input option for the underlying data source.
79+
"""
80+
self._jreader = self._jreader.option(key, value)
81+
return self
82+
7683
@since(1.4)
7784
def options(self, **options):
7885
"""Adds input options for the underlying data source.
@@ -235,6 +242,13 @@ def format(self, source):
235242
self._jwrite = self._jwrite.format(source)
236243
return self
237244

245+
@since(1.5)
246+
def option(self, key, value):
247+
"""Adds an output option for the underlying data source.
248+
"""
249+
self._jwrite = self._jwrite.option(key, value)
250+
return self
251+
238252
@since(1.4)
239253
def options(self, **options):
240254
"""Adds output options for the underlying data source.

python/pyspark/sql/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ def test_save_and_load_builder(self):
564564
self.assertEqual(sorted(df.collect()), sorted(actual.collect()))
565565

566566
df.write.mode("overwrite").options(noUse="this options will not be used in save.")\
567+
.option("noUse", "this option will not be used in save.")\
567568
.format("json").save(path=tmpPath)
568569
actual =\
569570
self.sqlCtx.read.format("json")\

0 commit comments

Comments
 (0)