当前位置:网站首页>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
边栏推荐
- 路径压缩、、
- 研发团队数字化转型实践
- [LeetCode304 Weekly Competition] Two questions about the base ring tree 6134. Find the closest node to the given two nodes, 6135. The longest cycle in the graph
- numpy.around
- problem solved
- 20220725资料更新
- 深度学习基础-基于Numpy的循环神经网络(RNN)实现和反向传播训练
- color transparency parameter
- Codeforces CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-D Solution
- Getting started with IDEA is enough to read this article
猜你喜欢

cmd command

y84. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (15)

cmd指令

Codeforces CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-D Solution

UML diagram of soft skills

cdh6打开oozieWeb页面,Oozie web console is disabled.

drf生成序列化类代码

CAKE:一个用于多视图知识图谱补全的可扩展性常识感知框架

访问控制台中的选定节点

C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
随机推荐
经典文献阅读之--DLO
DRF generating serialization class code
检查点是否在矩形内
UML diagram of soft skills
Calculate the angle of a line defined by two points
YOLO等目标检测模型的非极大值抑制NMS和评价指标(Acc, Precision, Recall, AP, mAP, RoI)、YOLOv5中[email protected]与
仿牛客网项目第三章:开发社区核心功能(详细步骤和思路)
Chapter 11 Working with Dates and Times
Nacos配置中心之加载配置
Chapter 19 Tips and Traps: Common Goofs for Novices
6132. 使数组中所有元素都等于零-快速排序法
How to use pywinauto and pyautogui to link the anime lady and sister please go home
Leetcode 129求根节点到叶节点数字之和、104二叉树的最大深度、8字符串转换整数(atoi)、82删除排序链表中的重复元素II、204二分查找、94二叉树的中序遍历、144二叉树的前序遍历
6134. 找到离给定两个节点最近的节点-力扣双百代码
Chapter 12 End-User Task As Shell Scripts
Avoid , ,
, and tagsnumpy.hstack
测试岗月薪5-9k,如何实现涨薪到25k?
程序员还差对象?new一个就行了
Create virtual environments with virtualenv and Virtualenvwrapper virtual environment management tools