apache-spark - Spark Streaming 输出模式“内存”显示无记录
问题描述
我在 VS Code 编辑器中运行 spark 流代码,我使用内存作为我的数据接收器,并且输出模式已完成。
当我尝试从内存表中查看结果时,它显示无输出。
任何帮助,将不胜感激
import sys
import findspark
findspark.init()
from pyspark.sql import SparkSession
from pyspark.sql.functions import explode
from pyspark.sql.functions import split
from pyspark.sql.types import *
sparkSession = SparkSession.builder.master('local').appName('Max_Stock in complete mode').getOrCreate()
sparkSession.sparkContext.setLogLevel('ERROR')
schema = StructType([StructField('Date', StringType(), True),
StructField('Open', StringType(), True),
StructField('High', DoubleType(), True),
StructField('Low', StringType(), True),
StructField('Close', StringType(), True),
StructField('Adjusted Close', StringType(), True),
StructField('Volume', StringType(), True),
StructField('Name', StringType(), True)
])
input_stream = """path"""
stockPricesDf = sparkSession.readStream.option('header', 'true').schema(schema).csv(input_stream)
print(' ')
print('Is the stream ready?')
print(stockPricesDf.isStreaming)
print(' ')
print('Schema of the input stream')
print(stockPricesDf.printSchema())
upDaysDf = stockPricesDf.select("Name", "Date","High", "Open", "Close").where("Open > Close")
upDays_max = upDaysDf.groupBy('Name').max('High')
query = upDays_max.writeStream.outputMode('complete').format('memory').queryName('datatable')\
.option('truncate', 'false') \
.option('numRows', 5) \
.start() \
.awaitTermination()
SparkSession.sql("select * from datatable ").show(5)
解决方案
推荐阅读
- cordova - 离子科尔多瓦资源--splash错误
- .net - VS Code C# 扩展报告缺少 .NETFramework,Version v4.5
- vba - 使用 VBA 复制 sql 语句
- node.js - GULP [Browsersync] 无法打开浏览器
- swift - 在 Swift 中使用 AVAssetWriter 将 AVCaptureVideoDataOutput 保存到电影文件
- openssl - 无法访问 IMAP/POP3 gmail
- python - 将浮点数转换为数组中的整数
- c++ - 为什么g ++在动态链接时会检测到未定义的引用
- javascript - 使用 Stripe 结帐的 Bootstrap 4 表单验证
- visual-studio-code - VSCode Minify 并自动上传到服务器