Spark导出数据文件到HDFS

spark.read.format("csv")

.option("nullValue", "")

.option("quote", "")

.option("header", "true")

.load(s"file:/root/test/networks.csv")

.createOrReplaceTempView("v1")

spark.table("v1").show(5)

val l = spark.table("v1").count()

println(s"l = ${l}")

spark.sql("INSERT OVERWRITE TABLE xxxx select * from v1")

res.coalesce(1).write.option("header", "true").csv(s"/root/test/res")

res.coalesce(1).write.option("header", "true").csv(s"hdfs://xxxxxx:9000/test/network/res")

/test/makt

val res2 =

spark.sql(

s"""

|select * from

|xxxx.xxxx limit 1;

|""".stripMargin)

res2.coalesce(1).write.option("header", "true").csv(s"file:/root/test/res2")

res2.coalesce(1).write.csv("/root/test/res.csv")

hdfs dfs -get /root/test/res/xxxx /root/test

相关推荐
IT_陈寒7 分钟前
为什么我的Java Stream操作总是默默吃掉异常?
前端·人工智能·后端
志尊宝13 分钟前
Vue3 零基础每日笔记(017):事件处理进阶——$event、多事件与事件修饰符全家桶
javascript·vue.js·笔记
光影少年33 分钟前
react navite浏览器 Event Loop 和 Node Event Loop 的区别
前端·javascript·react native·react.js·前端框架
90后的晨仔38 分钟前
uni-app 安卓自有证书完全指南
前端
CharlesYu0111 小时前
前端性能优化的第一性原理,是不断缩短“用户发起意图 → 获得可用结果”之间的时间
前端
平头哥技术团队11 小时前
Day 21 _ 页内锚点_给每段起个 id,目录写 href=_#id_,点一下页面就滚到那一段
前端·html·html5
子兮曰12 小时前
Bun v1.4.1 深度解析:从 Zig 到 Rust,一场 11 天、64 个 AI 代理的语言迁徙
前端·后端·bun
人民广场吃泡面13 小时前
什么是AI Agent?它又能给前端带来哪些效率提升?
前端·人工智能
中科三方13 小时前
两家域名注册商资质被ICANN终止:企业域名资产安全再受关注
前端·网络·安全·域名