将 DataFrame 的内容流式传输到数据源并返回 StreamingQuery 对象。
Syntax
start(path=None, format=None, outputMode=None, partitionBy=None, queryName=None, **options)
参数
| 参数 | 类型 | Description |
|---|---|---|
path |
str,可选 | Hadoop 支持的文件系统中的路径。 |
format |
str,可选 | 用于保存的格式。 |
outputMode |
str,可选 | 将数据写入接收器的方式: append, complete或 update。 |
partitionBy |
str 或 list,可选 | 分区列的名称。 |
queryName |
str,可选 | 查询的唯一名称。 |
**options |
所有其他字符串选项。 为大多数流提供 checkpointLocation ;流不需要 memory 。 |
退货
StreamingQuery
示例
df = spark.readStream.format("rate").load()
基本示例:
q = df.writeStream.format('memory').queryName('this_query').start()
q.isActive
# True
q.name
# 'this_query'
q.stop()
q.isActive
# False
使用触发器和其他参数:
q = df.writeStream.trigger(processingTime='5 seconds').start(
queryName='that_query', outputMode="append", format='memory')
q.name
# 'that_query'
q.isActive
# True
q.stop()