Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark spark structured steaming不在“中显示任何数据”;格式(“内存”)_Apache Spark_Apache Kafka_Apache Spark Sql_Spark Structured Streaming - Fatal编程技术网

Apache spark spark structured steaming不在“中显示任何数据”;格式(“内存”)

Apache spark spark structured steaming不在“中显示任何数据”;格式(“内存”),apache-spark,apache-kafka,apache-spark-sql,spark-structured-streaming,Apache Spark,Apache Kafka,Apache Spark Sql,Spark Structured Streaming,当我在下面做时,它工作正常 company_info_df.select(col("value")) .writeStream() .outputMode("append") .option("truncate", false) .format("console") .trigger(Trigger.ProcessingTime("4 seconds"))

当我在下面做时,它工作正常

company_info_df.select(col("value"))
             .writeStream()
              .outputMode("append")
              .option("truncate", false)
              .format("console")
              .trigger(Trigger.ProcessingTime("4 seconds"))
              .start();
但当我按照下面的方式,即“.format”(“memory”),它并没有显示任何内容

company_info_df.select(col("value"))
             .writeStream()
              .outputMode("append")
              .option("truncate", false)
              .format("memory")
              .queryName("company_info")
              .option("checkpointLocation", checkpointDir + "\\console")
              .trigger(Trigger.ProcessingTime("4 seconds"))
              .start();

        Dataset<Row> company_inf = sparkSession.sql("select * from company_info");

        company_inf.show();
company\u info\u df.选择(列(“值”))
.writeStream()
.outputMode(“追加”)
.选项(“截断”,false)
.格式(“内存”)
.queryName(“公司信息”)
.选项(“checkpointLocation”,checkpointDir+“\\console”)
.trigger(trigger.ProcessingTime(“4秒”))
.start();
数据集company\u inf=sparkSession.sql(“从company\u info中选择*);
公司信息显示();
我做错了什么?
正确的方法是什么?

参考spark shell中适用于示例数据的以下代码:

import org.apache.spark.sql.functions._
import org.apache.spark.sql.SparkSession
val spark = SparkSession.builder.appName("StructuredNetworkWordCount").getOrCreate()
import spark.implicits._
import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType};

val userSchema = new StructType().add("col1", "string").add("col2", "string").add("col3", "string").add("col4", "string").add("col5", "string").add("col6", "integer")
val csvDF = spark.readStream.option("sep", ",").schema(userSchema).csv("/user/Temp") //reads the stream as source files in a folder.
csvDF.createOrReplaceTempView("abcd");
val dbDf2 = spark.sql("select col2, sum(col6) from abcd group by col2");
dbDf2.writeStream.queryName("abcdquery").outputMode("complete").format("memory").start()
在您的代码中,尝试在写操作期间删除一些选项,看看哪里出了问题