Inside Spark SQL cover

Inside Spark SQL

Rating 3.9
Word count
376 words
Chapters
12
ISBN
9787121343148

Tags

Summary

Inside Spark SQL focuses on Spark SQL, the subsystem of Apache Spark responsible for structured data processing, dismantling its overall architecture and the implementation mechanisms of its internal modules from a source-code-level perspective. It was among the earlier Chinese technical books to systematically explain the internals of Spark SQL. The book has 11 chapters, broadly divided into four parts. Part One, background and foundations (Chapters 1–2), reviews the evolution of big data and Spark, of the relational model and SQL, and briefly introduces the RDD programming model and the basic concepts of DataFrame and Dataset. Part Two covers the stages of SQL implementation (Chapters 3–6): using a simple query as an example, it traces the complete execution path from SQL to RDD, introduces the three internal systems—InternalRow, TreeNode, and Expression—and the internal data type system, then examines in turn the ANTLR-based SQL parser, the generation of the logical plan (LogicalPlan) and the Analyzer, the Optimizer's rules, and the generation of the physical plan (PhysicalPlan) and common Strategies. Part Three consists of special topics (Chapters 7–10), focusing on the implementation of the two core operators, Aggregation and Join, analyzing in depth the memory management and code generation optimizations of the Tungsten project, and explaining how Spark SQL connects to Hive. Part Four is practice (Chapter 11), sharing experience in system modification and performance optimization in production environments. The book assumes readers already have some experience with Spark and a foundation in SQL, and is suited to engineers who want to move from "knowing the API" to "understanding the internals."

Editor's review

讲 Spark 的书不少,讲 Spark SQL 内核的书很少。多数资料停留在 API 用法和架构示意图的层面,一旦遇到执行慢、数据倾斜、计划不理想的问题,就只能凭经验试参数。这本书的价值在于把“为什么”讲清楚了:一条 SQL 从解析、绑定、逻辑优化到物理计划生成,再到算子执行和内存布局,每一步被拆成可以顺着源码读下去的链条。 它的结构安排比较克制。前两章只做背景与基础铺垫,熟悉 Spark 的读者可以直接跳到第 3 章;第 3~6 章用一个小案例把整条执行链路串起来,是全书的主干;第 7~10 章把 Aggregation、Join、Tungsten、Hive 连接分别做成专题深入;最后一章落到生产环境的改造与调优经验,避免了只读源码不接地气的问题。 需要提醒的是,本书出版于 2018 年,对应 Spark 2.x 时代的实现。Catalyst 的分阶段设计、InternalRow 与 Expression 体系、Tungsten 的内存管理与代码生成这些主干思想在后续版本中仍然延续,但具体的类名、接口和默认策略会随版本变化。把它当作“读懂执行链条的地图”,再对照手头版本的源码阅读,效果最好。

Who it's for

A good fit for

  • 已能写 Spark SQL / DataFrame 代码、想弄清内部执行机制的中高级开发者
  • 需要排查 Spark SQL 作业性能问题、做执行计划调优的数据平台工程师
  • 从事查询引擎或数据库内核研发,想借鉴 Catalyst 与 Tungsten 设计的技术人员
  • 以 Spark 源码为研究对象的分布式计算方向研究生与研究人员

Not a good fit for

  • 刚开始学大数据、还没有写过 Spark 作业的零基础读者
  • 只想快速上手写 SQL、不关心内部实现的分析人员
  • 急需针对 Spark 3.x 新特性(AQE、新版本优化器)做专题学习的人

Reading tips

  1. 先读第 3 章把“SQL 到 RDD”的整体链路建立起来,再回头补第 1~2 章基础,效率更高。
  2. 对照自己使用的 Spark 版本源码同步阅读,遇到类名或流程差异以本机代码为准。
  3. 读第 7~9 章前先准备一个带聚合和多表 Join 的实际查询,用 explain 观察计划变化。
  4. 把第 11 章的实践经验用于自己的作业调优,形成“现象—计划—源码”三段式排查习惯。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Chapter 1: Background of Spark SQL
  2. Chapter 2: Introduction to Spark Basics
  3. Chapter 3: Overview of the Spark SQL Execution Process
  4. Chapter 4: The Spark SQL Compiler Parser
  5. Chapter 5: The Spark SQL Logical Plan (LogicalPlan)
  6. Chapter 6: The Spark SQL Physical Plan (PhysicalPlan)
  7. Chapter 7: Implementing Aggregation in Spark SQL
  8. Chapter 8: Implementing Join in Spark SQL
  9. Chapter 9: Implementing Tungsten Technology
  10. Chapter 10: Connecting Spark SQL to Hive
  11. Chapter 11: Spark SQL Development and Practice
  12. References

FAQ

这本书讲的是哪个版本的 Spark?
本书 2018 年出版,内容基于 Spark 2.x 时代的实现,书中源码分析与类名均对应那一时期。后续版本中 Catalyst 的整体流程、Expression 体系与 Tungsten 思路仍基本延续,但具体实现与默认策略有变化,建议对照自己所用版本的源码阅读。
没有 Spark 基础能直接看吗?
不建议。作者在前言中明确说明,本书不展开讲解 RDD、调度等 Spark 基础知识,默认读者已熟悉 Spark 使用并具备 SQL 基础。完全没有经验的读者最好先通过官方文档或其他入门书补齐基础再读。
为什么目录没有列出全部小节?
本书章节下设大量小节(如 InternalRow 体系、TreeNode 体系、Analyzer 机制、Optimizer 规则体系等),层级较深。这里只列出章级目录,方便把握全书结构,具体小节可在书内或出版社页面的完整目录中查看。
读了它能解决线上 Spark SQL 慢的问题吗?
能提供判断依据而非现成答案。书中对逻辑计划优化规则、物理计划选择、Aggregation 与 Join 实现以及 Tungsten 内存与代码生成的剖析,能帮助理解执行计划为何如此生成;第 11 章还分享了生产环境的改造与调优经验,但具体调参仍需结合自身数据特征。
这本书和一般 Spark 入门书有什么区别?
一般 Spark 图书以 API 使用和框架介绍为主,覆盖面广而不深;本书不重复 Spark 基础,专注 Spark SQL 一个子系统的内核实现,大量内容直接对应源码逻辑,定位是帮助读者从“会用”走向“懂原理”。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

Huang Ming Author · China · 1961

Huang Ming, born in July 1961 in Dinghai, Zhejiang, is a professor and doctoral supervisor at the School of Software, Dalian Jiaotong University. His research focuses on enterprise informatization and computer-based management information systems. He has long served as chief editor of national computer rank examination preparation books as well as university textbooks on computer science and information systems. One work by him is currently included in the collection: Questions and Answers on the Prevention, Treatment, and Rehabilitation of Respiratory Infections in Traditional Chinese and Western Medicine, commonly classified under health. In this book, the author turns his teaching and research experience in computing and information systems toward popular health writing, organizing knowledge on the prevention, treatment, and rehabilitation of respiratory infections in both traditional Chinese and Western medicine in a question-and-answer format for easy reference. Given the limited public information available, a full assessment of his health writing and its influence is difficult.

More by the same author

Top rated in the same category