Presto Distributed SQL Query Engine

repository·master·Indexed 12 days ago

https://github.com/prestodb/presto

A distributed SQL query engine designed for high-performance big data analytics, allowing interactive queries against multiple data sources using standard SQL. Includes documentation on Presto Benchto for macro benchmarking, Presto Native Execution (Prestissimo) using Velox, and the C++ protocol generation pipeline for Thrift serialization.

Tokens
312.6K
Snippets
884
Records
1.3K
Agent score
96%

What's inside Presto

  1. Overview of the Presto Proxy service

    master

    The Presto Proxy is a service designed to allow clients to securely access remote Presto servers (or a cluster of servers) that are not directly reachable, such as those behind a firewall.

    Key features include:

    • Protocol Awareness: The proxy natively understands the Presto protocol and automatically rewrites the nextUri field in response payloads. This ensures that subsequent requests from the client are directed to the proxy instead of the remote server.
    • Secure Authentication via JWT: When configured, the proxy can generate JSON Web Token (JWT) access tokens. These tokens contain the principal extracted from the TLS client certificate presented to the proxy, enabling secure environments without requiring the proxy to perform explicit username/principal validation.

    Important Limitation: The proxy does not hide remote URIs. Clients will still be able to see the hostnames and IP addresses of the remote servers.

  2. What is PrestoDB and its core mission

    master

    PrestoDB is an open-source distributed SQL query engine designed for high-speed analytic queries against data sources ranging from gigabytes to petabytes.

    Key Capabilities for Users:

    • High Performance: Supports low-latency interactive workloads, ad-hoc exploratory analytics, and large-scale batch workloads.
    • Scalability: Engineered to access and process massive amounts of data from data lakes.
    • Connectivity: Features a highly customizable plugin infrastructure, including pluggable storage connectors, to adapt to changing infrastructure.
    • User-Friendly Interface: Uses familiar ANSI-style SQL syntax and includes an optimizer designed to produce efficient query plans with sensible defaults.
  3. Overview of Presto C++ (Prestissimo)

    master

    Presto C++ (development name: Prestissimo) is a high-performance, drop-in replacement for Presto workers written in C++. It is built on the Velox library and uses the Proxygen C++ HTTP framework to implement the same RESTful endpoints as Java workers.

    Key characteristics:

    • No JVM Required: Because communication with the Java coordinator and between workers occurs via REST endpoints, Presto C++ workers do not use JNI and do not require a JVM on worker nodes.
    • Sidecar Mode: A Presto C++ worker can be configured as a sidecar using the NativeSidecarPlugin. This allows the worker to provide additional information to the Java coordinator (such as session properties and functions) via additional REST endpoints. It is recommended to have at least one sidecar worker in a Presto C++ cluster.
  4. Overview of Presto SQL Helpers modules

    master

    Presto SQL Helpers provides inline SQL-invoked functions via two distinct plugin modules:

    1. presto-sql-invoked-functions-plugin: Used for Java-based clusters and native-only clusters (those without a sidecar).
    2. presto-native-sql-invoked-functions-plugin: Used specifically for native clusters that are sidecar-enabled.
  5. Overview of the Presto REST API

    master

    Presto provides a REST API to interact with the cluster. The API is organized into several resource categories that allow you to manage and monitor the lifecycle of the cluster and its workloads. The primary resource types available are:

    • Node: Manage and inspect cluster nodes.
    • Query: Manage and monitor SQL queries (execution, status, and results).
    • Stage: Inspect the execution stages of a query.
    • Statement: Interact with specific statements within the engine.
    • Task: Monitor individual tasks within a query stage.
  6. Overview of Presto product tests

    master

    Presto product tests use user-visible interfaces (such as presto-cli) to verify Presto's correctness through end-to-end execution. Unlike unit tests, these tests exercise the entire codebase.

    Tests are executed using the Tempto harness. The environment typically consists of a Docker container running Hadoop in pseudo-distributed mode, with Presto running either in Docker containers (pseudo-distributed or distributed) or manually from an IDE like IntelliJ for debugging. Tests run in a separate JVM using scripts located in presto-product-tests/bin.

  7. Optimizations influenced by History Based Optimization (HBO)

    master

    Several core Presto optimizations leverage HBO statistics when enabled:

    • DetermineJoinDistributionType & DetermineSemiJoinDistributionType: Decides between broadcast or repartition joins using recorded data sizes from history. Falls back to cost model statistics if HBO is disabled or unavailable.
    • ReorderJoins: Reorders join sequences based on input and output sizes recorded from history queries.
    • PushPartialAggregationThroughExchange: Uses historical partial aggregation output sizes to decide on aggregation splitting (see configuration details).
    • ScaledWriterRule: Uses historical write task counts to determine the starting number of tasks.
    • RandomizeNullKeyInOuterJoin: Uses historical NULL key counts and ratios to mitigate skew (see configuration details).
  8. Understand the Presto Console structure

    master

    The Presto Console is a built-in dashboard for monitoring cluster information, running SQL queries, query details, and resource groups. It consists of HTML pages and JavaScript files that interact with Presto APIs via the coordinator.

    The source code is located in the presto-ui/src directory (referred to as the Presto Console root).

    Directory Layout:

    • Presto Console root: Contains static HTML pages.
    • src/static: Static assets (favicon, logo, Presto CSS).
    • src/static/dev: Contains the Query Viewer page and its JS file.
    • src/static/vendor: Third-party JS/CSS libraries.
    • src/: UI components and the webpack.config.js file.