How Query Engines Work
$19.99
Minimum price
$29.99
Suggested price

How Query Engines Work

An Introductory Guide

About the Book

Andy Grove has worked on numerous projects that required custom query engines or integrations with existing query engines and this book provides an approachable introduction to the topic.

The book provides an introduction to the high-level concepts behind query engines and walks through every step of building a SQL query engine in Kotlin with full source code available in a companion github repository. Most of the book is programming language agnostic and Kotlin was chosen for the code examples due to its conciseness and readability. The concepts should be easily translatable to other programming languages.

Andy is a PMC member of Apache Arrow where he donated the initial Rust implementation and later donated the DataFusion query engine.

Please note that this is a short introductory book (around 100 pages). Around 4% of readers ask for a refund because they were expecting something far more comprehensive.

  • Share this book

  • Feedback

    You must own a copy of this Book to access the forums.

    Email the Author(s)

About the Author

Andy Grove
Andy Grove

Andy Grove is a PMC member of Apache Arrow where he donated the initial Rust implementation and also donated the DataFusion query engine.

Table of Contents

  • Acknowledgments
  • Introduction
    • Feedback
  • 1 What Is a Query Engine?
    • 1.1 Why Are Query Engines Popular?
    • 1.2 What This Book Covers
    • 1.3 Source Code
    • 1.4 Why Kotlin?
  • 2 Apache Arrow
    • 2.1 Arrow Memory Model
    • 2.2 Inter-Process Communication (IPC)
    • 2.3 Compute Kernels
    • 2.4 Arrow Flight Protocol
    • 2.5 Arrow Flight SQL
    • 2.6 Query Engines
  • 3 Choosing a Type System
    • 3.1 Row-Based or Columnar?
    • 3.2 Interoperability
    • 3.3 Type System
  • 4 Data Sources
    • 4.1 Data Source Interface
    • 4.2 Data Source Examples
  • 5 Logical Plans & Expressions
    • 5.1 Printing Logical Plans
    • 5.2 Serialization
    • 5.3 Logical Expressions
    • 5.4 Column Expressions
    • 5.5 Literal Expressions
    • 5.6 Binary Expressions
    • 5.7 Comparison Expressions
    • 5.8 Boolean Expressions
    • 5.9 Math Expressions
    • 5.10 Aggregate Expressions
    • 5.11 Logical Plans
    • 5.12 Scan
    • 5.13 Projection
    • 5.14 Selection (also known as Filter)
    • 5.15 Aggregate
  • 6 Building Logical Plans
    • 6.1 Building Logical Plans The Hard Way
    • 6.2 Building Logical Plans using DataFrames
  • 7 Physical Plans & Expressions
    • 7.1 Physical Expressions
    • 7.2 Column Expressions
    • 7.3 Literal Expressions
    • 7.4 Binary Expressions
    • 7.5 Comparison Expressions
    • 7.6 Math Expressions
    • 7.7 Aggregate Expressions
    • 7.8 Physical Plans
    • 7.9 Scan
    • 7.10 Projection
    • 7.11 Selection (also known as Filter)
    • 7.12 Hash Aggregate
  • 8 Query Planner
    • 8.1 Translating Logical Expressions
    • 8.2 Column Expressions
    • 8.3 Literal Expressions
    • 8.4 Binary Expressions
    • 8.5 Translating Logical Plans
    • 8.6 Scan
    • 8.7 Projection
    • 8.8 Selection (also known as Filter)
    • 8.9 Aggregate
  • 9 Query Optimizations
    • 9.1 Rule-Based Optimizations
    • 9.2 Projection Push-Down
    • 9.3 Predicate Push-Down
    • 9.4 Cost-Based Optimizations
  • 10 Query Execution
    • 10.1 Apache Spark Example
    • 10.2 KQuery Examples
    • 10.3 Removing The Query Optimizer
  • 11 SQL Support
    • 11.1 Tokenizer
    • 11.2 Pratt Parser
    • 11.3 Parsing SQL Expressions
    • 11.4 Parsing a SELECT statement
    • 11.5 SQL Query Planner
    • 11.6 Translating SQL Expressions
    • 11.7 Planning SELECT
    • 11.8 Planning for Aggregate Queries
  • 12 Parallel Query Execution
    • 12.1 Combining Results
    • 12.2 Smarter Partitioning
    • 12.3 Partition Keys
    • 12.4 Parallel Joins
  • 13 Distributed Query Execution
    • 13.1 Distributed Query Scheduling
    • 13.2 Managing Compute Resources
    • 13.3 Serializing a Query Plan
    • 13.4 Serializing Data
    • 13.5 Choosing a Protocol
    • 13.6 Streaming
    • 13.7 Custom Code
    • 13.8 Distributed Query Optimizations
    • 13.9 Recovering from Distributed Query Failures
  • 14 Testing
    • 14.1 Unit Testing
    • 14.2 Integration Testing
    • 14.3 Fuzzing
  • 15 Benchmarks
    • 15.1 Measuring Performance
    • 15.2 Measuring Scalability
    • 15.3 Concurrency
    • 15.4 Automation
    • 15.5 Comparing Benchmarks
    • 15.6 Publishing Benchmark Results
  • Further Resources
    • Open-Source Projects
    • YouTube
    • Sample Data

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$11,214,979writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub