码迷,mamicode.com
首页 > 数据库 > 详细

COMP9313 week7b Spark SQL

时间:2020-07-19 00:39:19      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:json   can   width   bsp   physical   drive   because   ram   mat   

https://www.cse.unsw.edu.au/~cs9313/20T2/slides/L6.pdf

 

Table recall:

  1. rows: entity

  2. columns: attributes

Spark SQL:

  1. Spark SQL is not about sql, Aims to Create and Run Spark programs faster

  2. RDD 与 Spark SQL 操作算平均乘积

技术图片

 

 技术图片

 

 DataFrame:

  1.  faster than Spark SQL in single machine

  2. DataFrames APS is an extension to the existing RDD API

  3. SparkSession is the entry point of DataFrame API

    spark = SparkSession.builder.config(conf=conf).getOrCreate()

    df = spark.read.format( ‘json‘ ).load(‘example.json‘)

    df.show()

  4. sql() enables applications to run SQL queries programmatically and returns the result as a DataFrame.

  5. You can mix DataFrame methods and SQL queries in the same code.

  6.  DataFrames are lazy.  Actions cause the execution of the query

  7. DataFrames uses columnar storage

    1)保证每行的数据是相同type

  技术图片 

 

 

   技术图片

 

  技术图片

 

   技术图片

 

   技术图片

 

 

 DataFrame and RDD

  1. •DataFrames are built on top of the Spark RDD API

    1)You can use normal RDD operations on DataFrames

  2.Stick with the DataFrame API if possible

    1)Using RDD operations will often give you back an RDD, not a DataFrame

    2)The DataFrame API is likely to be more efficient, because it can optimize the underlying operations with Catalyst

 

Spark SQL:

  1. Plan optimization and Execution

    1) logical plan 

      Logical Plan is an abstract of all transformation steps that need to be performed

      • It does not refer anything about the Driver (Master Node) or Executor (Worker Node)

      • SparkContext is responsible for generating and storing it

      • Unresolved Logical Plan

      • Resolved Logical Plan

      • Optimized Logical Plan

    2) physical plans

       

COMP9313 week7b Spark SQL

标签:json   can   width   bsp   physical   drive   because   ram   mat   

原文地址:https://www.cnblogs.com/ChevisZhang/p/13338037.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!