- Mastering Apache Spark 2.x(Second Edition)
- Romeo Kienzler
- 266字
- 2021-07-02 18:55:27
The SparkSession--your gateway to structured data processing
The SparkSession is the starting point for working with columnar data in Apache Spark. It replaces SQLContext used in previous versions of Apache Spark. It was created from the Spark context and provides the means to load and save data files of different types using DataFrames and Datasets and manipulate columnar data with SQL, among other things. It can be used for the following functions:
- Executing SQL via the sql method
- Registering user-defined functions via the udf method
- Caching
- Creating DataFrames
- Creating Datasets
Using the SparkSession allows you to implicitly convert RDDs into DataFrames or Datasets. For instance, you can convert RDD into a DataFrame or Dataset by calling the toDF or toDS methods:
import spark.implicits._
val rdd = sc.parallelize(List(1,2,3))
val df = rdd.toDF
val ds = rdd.toDS
As you can see, this is very simple as the corresponding methods are on the RDD object itself.
Next, we will examine some of the supported file formats available to import and save data.
- Getting Started with Gulp(Second Edition)
- 實戰Java程序設計
- 機械工程師Python編程:入門、實戰與進階
- KnockoutJS Starter
- 深入理解Android:Wi-Fi、NFC和GPS卷
- Java實戰(第2版)
- Microsoft Dynamics AX 2012 R3 Financial Management
- Android開發三劍客:UML、模式與測試
- INSTANT Silverlight 5 Animation
- Web性能實戰
- C++ Fundamentals
- Mastering jQuery Mobile
- 超簡單:Photoshop+JavaScript+Python智能修圖與圖像自動化處理
- C++服務器開發精髓
- Google Maps JavaScript API Cookbook