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

相关推荐
空中湖5 分钟前
用 React 写数据大屏:为什么我不建议用图表库
前端·react.js·前端框架
欣欣之王来了2 小时前
原始HTML插值:v-html指令的使用与安全风险
前端·学习·架构·项目·vue3教程
IT_陈寒2 小时前
Redis的LRU淘汰策略坑了我一整天
前端·人工智能·后端
计算机魔术师2 小时前
砍半价格、参数再涨,国产旗舰追到 Opus 鼻尖了
前端
特立独行的猫A2 小时前
10 MB 的桌面 AI 客户端:用仓颉 + 系统 WebView 替代 Electron
前端·harmonyos
修炼的dance3 小时前
白底图存JPG,sharp开mozjpeg背景杂点少近三成
前端
anOnion3 小时前
构建无障碍组件之Grid Pattern
前端·html·交互设计
乔旭伟3 小时前
Vben3 中后台表格封装实战:useVbenVxeGrid 的全局收敛与七个坑
前端·anti-design-vue·1024程序员节
鶴哥只手遮天4 小时前
jQuery 4.0 源码架构与工程实践-第 10 章 尺寸、几何与显隐
前端·javascript·jquery
Mia_墨黎4 小时前
2026 Windows 11 终端美化完全指南
前端·后端