首页 > 数据库 >day07 sparksql 生成Physical Plan

day07 sparksql 生成Physical Plan

时间:2023-04-03 22:59:06浏览次数:45  
标签:23 day07 +- sparksql sql apache org spark Physical

  1. 案例sql

select A,B  from testdata2 where A>2

 对应的执行计划:

== Analyzed Logical Plan ==
Project [A#23, B#24]
+- Filter (A#23 > 2)
   +- SubqueryAlias testdata2
      +- View (`testData2`, [a#23,b#24])
         +- SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
            +- ExternalRDD [obj#22]

== Optimized Logical Plan ==
Project [A#23, B#24]
+- Filter (A#23 > 2)
   +- SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
      +- ExternalRDD [obj#22]

== Physical Plan ==
Project [A#23, B#24]
+- Filter (A#23 > 2)
   +- SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
      +- Scan[obj#22]

== executedPlan ==
*(1) Project [A#23, B#24]
+- *(1) Filter (A#23 > 2)
   +- *(1) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
      +- Scan[obj#22]

 

1.1 该sql涉及的策略以及策略执行后得到的物理执行计划

========================涉及的策略:class org.apache.spark.sql.execution.SparkStrategies$SpecialLimits$============================
List(PlanLater Project [A#23, B#24])

========================涉及的策略:class org.apache.spark.sql.execution.SparkStrategies$BasicOperators$============================
List(Project [A#23, B#24]
+- PlanLater Filter (A#23 > 2)
)

========================涉及的策略:class org.apache.spark.sql.execution.SparkStrategies$BasicOperators$============================
List(Filter (A#23 > 2)
+- PlanLater SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
)

========================涉及的策略:class org.apache.spark.sql.execution.SparkStrategies$BasicOperators$============================
List(SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).a AS a#23, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData2, true])).b AS b#24]
+- PlanLater ExternalRDD [obj#22]
)

========================涉及的策略:class org.apache.spark.sql.execution.SparkStrategies$BasicOperators$============================
List(Scan[obj#22]
)

打印起作用的策略以及策略作用后的结果代码如下:

    val candidates = strategies.iterator.flatMap{ stra =>
      val my_plan = stra(plan)
      if(my_plan.size>0){
        println("========================涉及的策略:"+stra.getClass+"============================")
        println(my_plan)
        println()
      }
      my_plan
    }

 

2 . 代码作用细节:

2.1 代码入口:

  

  

 

 

 

 

 

 

 

 

 

 

 

 

标签:23,day07,+-,sparksql,sql,apache,org,spark,Physical
From: https://www.cnblogs.com/jj1106/p/17284753.html

相关文章

  • 学习记录:day07笔记
    进制转换1、为什么使用二进制、八进制、十六进制?因为目前CPU只能识别高低两种电平,只能对二进制数据进行计算二进制虽然能够直接别计算机识别但是不方便人去书写和记......
  • day07-SpringBoot接收参数相关注解
    SpringBoot接收参数相关注解1.基本介绍SpringBoot接收客户端提交数据/参数会使用到相关注解详解@PathVariable、@RequestHeader、@ModelAttribute、@RequestParam、@Co......
  • day07
    day07面向对象面向对象三大特性:封装、继承、多态类设计技巧1.一定要保证数据私有这是最重要的;绝对不要破坏封装性。2.一定要对数据初始化Java不对局部变量进行初始......
  • day07
    day07面向对象面向对象三大特性:封装、继承、多态类设计技巧1.一定要保证数据私有这是最重要的;绝对不要破坏封装性。2.一定要对数据初始化Java不对局部变量进行初始......
  • Day07-Request&Response
    Request&Response今日目标掌握Request对象的概念与使用掌握Response对象的概念与使用能够完成用户登录注册案例的实现能够完成SqlSessionFactory工具类的抽取1.R......
  • day07 (2023.3.7)
    1.方法小练习: 运行结果:2.方法重载: 3.递归 4.面向对象编程(OOP)  5.类 运行结果: 6.构造方法 7.构造方法的重载 结果循环,进入面向对象。小......
  • 路飞项目---day07()
    昨日回顾#GIt内容大回顾#1版本管理软件:git,svn -代码合并-代码版本管理-协同开发,合并代码#2git跟svn区别#3git安装:相应平台软件,下载完成,一路下......
  • day07-MyBatis的关联映射01
    MyBatis的关联映射Mybatis的关联映射实际的开发中,对数据库的操作常常会涉及到多张表,这在面向对象中就涉及到了对象与对象之间的关联关系。针对多表之间的操作,MyBatis提......
  • 02_07_Java语音进阶||day07_等待与唤醒案例、线程池、Lambda表达式
    第一章等待唤醒机制1.1线程间通信概念:多个线程在处理同一个资源(包子),但是处理的动作(线程的任务)却不相同。比如:线程A用来生产包子的,线程B用来吃包子的,包子可以理解......
  • 【jeecg-boot项目开发crm】:day07JeecgBoot-零基础入门视频-05代码生成(树模型和一对多
    代码生成(树模型和一对多模型,一对多三套模型)树模型生成流程图前期工作:先将页面搭建好页面中代码生成一对多生成流程图只能选主表将生成代码中的vue拷贝到前端目录下接下来......