当前位置:网站首页>The Spark of Sql join on the and and where
The Spark of Sql join on the and and where
2022-08-01 23:36:00 【Nanfeng knows my intentions】
需求
How to achieve the above requirements.先给出结论:join whre
join where
val df1: DataFrame = sc.makeRDD(Seq((1, "xm"), (2, "xl"), (3, "xw"))).toDF("id", "name")
df1.show()
df1.createOrReplaceTempView("t1")
val df2: DataFrame = sc.makeRDD(Seq(1,2)).toDF("id")
df2.createOrReplaceTempView("t2")
df2.show()
println("------------------------where------------------------------------")
val sql1:String =
s""" |select t1.id,t1.name from t1 |left join t2 |on t1.id = t2.id |where t2.id is NULL |""".stripMargin
session.sql(sql1).show()
+---+----+
| id|name|
+---+----+
| 1| xm|
| 2| xl|
| 3| xw|
+---+----+
+---+
| id|
+---+
| 1|
| 2|
+---+
------------------------where------------------------------------
+---+----+
| id|name|
+---+----+
| 3| xw|
+---+----+
join and
println("------------------------and------------------------------------")
val sql2:String =
s""" |select t1.id,t1.name from t1 |left join t2 |on t1.id = t2.id |and t2.id is NULL |""".stripMargin
session.sql(sql2).show()
------------------------and------------------------------------
+---+----+
| id|name|
+---+----+
| 1| xm|
| 2| xl|
| 3| xw|
+---+----+
原因分析
sql执行顺序:
FROM
ON
JOIN
WHERE
GROUP BY
WITH CUBE or WITH ROLLUP
HAVING
SELECT
DISTINCT ORDER BY TOP
For a detailed explanation of the connection, please refer to the article I wrote earlier
边栏推荐
- CAKE:一个用于多视图知识图谱补全的可扩展性常识感知框架
- Avoid , ,
, and tags - IDEA入门看这一篇就够了
- [LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环
- Nacos配置中心之加载配置
- chrome复制一张图片的base64数据
- Deep Learning Fundamentals - Numpy-based Recurrent Neural Network (RNN) implementation and backpropagation training
- 几道关于golang并发的面试题
- color transparency parameter
- 深度学习基础-基于Numpy的循环神经网络(RNN)实现和反向传播训练
猜你喜欢
Dynamic Scene Deblurring with Parameter Selective Sharing and Nested Skip Connections
Data Organization --- Chapter 5 Trees and Binary Trees --- The Concept of Binary Trees --- Application Questions
在CDH的hue上的oozie出现,提交 Coordinator My Schedule 时出错
Making a Simple 3D Renderer
cmd指令
cdh6打开oozieWeb页面,Oozie web console is disabled.
中职网络安全竞赛B7比赛部署流程
[Camp Experience Post] 2022 Cybersecurity Summer Camp
还在纠结报表工具的选型么?来看看这个
数据机构---第五章树与二叉树---二叉树的概念---应用题
随机推荐
程序员还差对象?new一个就行了
drf生成序列化类代码
Additional Features for Scripting
numpy.around
Flink学习第三天——一文带你了解什么是Flink流?
递归:方法调用自身
The third chapter of the imitation cattle network project: develop the core functions of the community (detailed steps and ideas)
C语言——分支语句和循环语句
cmd指令
Interpretation of the paper (GSAT) "Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism"
Chapter 12 End-User Task As Shell Scripts
Is TCP reliable?Why?
怎样做才能让这条SQL变成一条危险的SQL?
Background project Express-Mysql-Vue3-TS-Pinia page layout-sidebar menu
[C language advanced] file operation (2)
vscode hide menu bar
Oracle 数据库设置为只读及读写
color transparency parameter
Quartus 使用 tcl 文件快速配置管脚
Making a Simple 3D Renderer