Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/12320#discussion_r59917973
--- Diff: python/pyspark/sql/readwriter.py ---
@@ -426,6 +488,68 @@ def save(self, path=None, format=None, mode=None,
partitionBy=None, **options):
else:
self._jwrite.save(path)
+ @ignore_unicode_prefix
+ @since(2.0)
+ def startStream(self, path=None, format=None, mode=None,
partitionBy=None,
+ queryName=None, checkpointLocation=None, trigger=None,
**options):
+ """Saves the contents of the :class:`DataFrame` to a data source.
+
+ The data source is specified by the ``format`` and a set of
``options``.
+ If ``format`` is not specified, the default data source configured
by
+ ``spark.sql.sources.default`` will be used.
+
+ :param path: the path in a Hadoop supported file system
+ :param format: the format used to save
+ :param mode: specifies the behavior of the save operation when
data already exists.
+
+ * ``append``: Append contents of this :class:`DataFrame` to
existing data.
+ * ``overwrite``: Overwrite existing data.
+ * ``ignore``: Silently ignore this operation if data already
exists.
+ * ``error`` (default case): Throw an exception if data already
exists.
+ :param partitionBy: names of partitioning columns
+ :param queryName: unique name for the query
+ :param trigger: Set the trigger for the stream query. The default
value is
+ `ProcessingTime(0)` and it will run as fast as possible.
+ :param checkpointLocation: An optional location for checkpointing
state and metadata.
+ :param options: all other string options
+
+ >>> temp = tempfile.mkdtemp()
+ >>> cq = sdf.write.format('text').startStream(os.path.join(temp,
'out'),
+ ... checkpointLocation=os.path.join(temp, 'chk'))
+ >>> cq.isActive
+ True
+ >>> cq.stop()
+ >>> cq.isActive
+ False
+ >>> from pyspark.sql.streaming import ProcessingTime
+ >>> cq = sdf.write.startStream(os.path.join(temp, 'out'),
format='text',
+ ... queryName='my_query', trigger=ProcessingTime('5 seconds'),
+ ... checkpointLocation=os.path.join(temp, 'chk'))
+ >>> cq.name
+ u'my_query'
+ >>> cq.isActive
+ True
+ >>> cq.stop()
--- End diff --
Is there anyway to simplify this? I'd rather have good unit tests and very
simple doc tests.
---
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]