惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
WordPress大学
WordPress大学
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
L
LangChain Blog
雷峰网
雷峰网
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
NISL@THU
NISL@THU
Scott Helme
Scott Helme
量子位
S
Security Affairs
T
Threat Research - Cisco Blogs
博客园_首页
云风的 BLOG
云风的 BLOG
D
Docker
AWS News Blog
AWS News Blog
腾讯CDC
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
U
Unit 42
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Last Watchdog
The Last Watchdog
C
Cybersecurity and Infrastructure Security Agency CISA
IT之家
IT之家
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
F
Full Disclosure
L
Lohrmann on Cybersecurity
The Hacker News
The Hacker News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
S
Security @ Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
I
InfoQ

博客园 - cindy_zl

SAP SD销售与分销模块 Agent认知框架ReAct&Plan RAG系统优化 RAG检索优化 RAG架构 SAA-C02-架构师助理级-英文版-Q1 scala-数组 navicat mysql创建存储过程报错 安装完kali出现中文乱码 SPARK SQL ERROR: Detected cartesian product for INNER join between logical plans报错解决方法 scala的lazy关键字 scala集合三大类(seq序列,set集,map映射)——map映射 scala集合三大类(seq序列,set集,map映射)——set集合 scala集合三大类(seq序列,set集,map映射)——list序列 scala元组及拉链操作 scala的map映射 scala数组 scala方法和涵数的声明以及方法转换成涵数 scala的基础数据类型&if条件表达式&for循环
Spark SQL是处理结构化的数据
cindy_zl · 2019-10-04 · via 博客园 - cindy_zl

Spark SQL是处理结构化的数据,可以存储在二维表中,类似数据库中的表一样存储数据

Spark1.x

      val sqlContext = new SparkContext(conf)

      val sqlContext = new SQLContext(sc)

     //将RDD和Schema信息关联到一起,1,RDD和case class 2,RDD和StructType

    //case class Person将RDD中的数据转换成case class 属性相对应的类型,然后设置到case class中

    val rdd:RDD[Person] = ....

    //将RDD转换成DataFrame

    val df = rdd.toDF

    //对df进行操作(1,直接使用DataFrame上的算子DSL。2,写SQL)

   //将df注册成临时表

   df.registerTempTable("t_person")

  //执行SQL

  val result :DataFrame = sqlContext.sql("select * from t_person");

   result.show()

Spark2.x

val spark = SparkSession.builder().appName("a").master("local[*]").getOrCreate()

//创建DF

val df = spark.createDataFrame(RDD[Row], schema)

//DSL 和 SQL

df.createTempView("v_user")

//执行SQL

val result:DataFrame = spark.sql("select * from t_user")

//执行action

result.show()

//