How to write Spark Structured Streaming Data into Hive?

南笙酒味 提交于 2019-12-06 08:20:28

问题


How to write Spark Structured Streaming Data into Hive?

There is df.write().saveAsTable(tablename) however I am not sure if this writes streaming data

I normally do df.writeStream().trigger(new ProcessingTime(1000)).foreach(new KafkaSink()).start() to write streaming data into Kafka but I don't see anything similar to write streaming data into Hive data warehouse. any ideas?


回答1:


df.createOrReplaceTempView("mytable") 
spark.sql("create table mytable as select * from mytable");

or

df.write().mode(SaveMode.Overwrite).saveAsTable("dbName.tableName");


来源:https://stackoverflow.com/questions/45796006/how-to-write-spark-structured-streaming-data-into-hive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!