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

相关推荐
kyriewen3 小时前
微软用Go重写TypeScript编译器,速度提升10倍,网友:这是“背叛”还是“救赎”?
前端·typescript·ecmascript 6
Ceelog3 小时前
久坐党自救指南:屏幕前 8 小时,身体到底在经历什么
前端·后端
西陵3 小时前
Agent 为什么会陷入 Doom Loop?OpenClaw 的破解之道
前端·人工智能·ai编程
Hyyy4 小时前
普通前端续命周报——第2周
前端
swipe4 小时前
DeepAgents 实战:用多 Agent 架构搭一个深度调研助手
javascript·面试·llm
wuxinyan1234 小时前
工业级大模型学习之路030:Streamlit 企业级智能体前端工作台
前端·学习·streamlit·智能体
修己xj4 小时前
告别无效刷屏!TrendRadar:最快30秒部署的开源热点助手,让你只看真正关心的新闻
前端
anOnion5 小时前
构建无障碍组件之Slider Pattern
前端·html·交互设计
云水一下5 小时前
JavaScript 从零基础到精通系列:前世今生与编程启蒙
前端·javascript
月亮邮递员6165 小时前
Markdown语法总结
开发语言·前端·javascript