MCPcopy
hub / github.com/prestodb/presto

github.com/prestodb/presto @0.298.1 sqlite

repository ↗ · DeepWiki ↗ · release 0.298.1 ↗
105,920 symbols 545,538 edges 9,685 files 3,306 documented · 3%
README

Presto

LFX Health Score

Presto is a distributed SQL query engine for big data.

See the Presto installation documentation for deployment instructions.

See the Presto documentation for general documentation.

Mission and Architecture

See PrestoDB: Mission and Architecture.

Requirements

  • Mac OS X or Linux
  • Java 17 64-bit. Both Oracle JDK and OpenJDK are supported.
  • Maven 3.6.3+ (for building)
  • Python 2.4+ (for running with the launcher script)

Building Presto

Overview (Java)

Presto is a standard Maven project. Simply run the following command from the project root directory:

./mvnw clean install

On the first build, Maven will download all the dependencies from the internet and cache them in the local repository (~/.m2/repository), which can take a considerable amount of time. Subsequent builds will be faster.

When building multiple Presto projects locally, each project may write updates to the user's global M2 cache, which could cause build issues. You can configure your local .mvn/maven.config to support a local cache specific to that project via -Dmaven.repo.local=./.m2/repository.

Presto has a comprehensive set of unit tests that can take several minutes to run. You can disable the tests when building:

./mvnw clean install -DskipTests

After building Presto for the first time, you can load the project into your IDE and run the server. We recommend using IntelliJ IDEA. Because Presto is a standard Maven project, you can import it into your IDE using the root pom.xml file. In IntelliJ, choose Open Project from the Quick Start box or choose Open from the File menu and select the root pom.xml file.

After opening the project in IntelliJ, double check that the Java SDK is properly configured for the project:

  • Open the File menu and select Project Structure
  • In the SDKs section, ensure that a distribution of JDK 17 is selected (create one if none exist)
  • In the Project section, ensure the Project language level is set to at least 8.0.
  • When using JDK 17, an IntelliJ bug requires you to disable the Use '--release' option for cross-compilation (Java 9 and later) setting in Settings > Build, Execution, Deployment > Compiler > Java Compiler. If this option remains enabled, you may encounter errors such as: package sun.misc does not exist because IntelliJ fails to resolve certain internal JDK classes.

Presto comes with sample configuration that should work out-of-the-box for development. Use the following options to create a run configuration:

  • Main Class: com.facebook.presto.server.PrestoServer
  • VM Options: -ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties -Djdk.attach.allowAttachSelf=true
  • Working directory: $MODULE_WORKING_DIR$ or $MODULE_DIR$(Depends your version of IntelliJ)
  • Use classpath of module: presto-main

The working directory should be the presto-main subdirectory. In IntelliJ, using $MODULE_DIR$ accomplishes this automatically.

Additionally, the Hive plugin must be configured with location of your Hive metastore Thrift service. Add the following to the list of VM options, replacing localhost:9083 with the correct host and port (or use the below value if you do not have a Hive metastore):

-Dhive.metastore.uri=thrift://localhost:9083

To modify the loaded plugins in IntelliJ, modify the config.properties located in presto-main/etc. You can modify plugin.bundles with the location of the plugin pom.xml

Additional configuration for Java 17

When running with Java 17, additional --add-opens flags are required to allow reflective access used by certain catalogs based on which catalogs are configured. For the default set of catalogs loaded when starting the Presto server in IntelliJ without changes, add the following flags to the VM Options:

--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.ref=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.security=ALL-UNNAMED
--add-opens=java.base/javax.security.auth=ALL-UNNAMED
--add-opens=java.base/javax.security.auth.login=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/java.util.regex=ALL-UNNAMED
--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens=java.base/sun.security.action=ALL-UNNAMED
--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED

These flags ensure that internal JDK modules are accessible at runtime for components used by Presto’s default configuration. It is not a comprehensive list. Additional flags may need to be added, depending on the catalogs configured on the server.

Using SOCKS for Hive or HDFS

If your Hive metastore or HDFS cluster is not directly accessible to your local machine, you can use SSH port forwarding to access it. Setup a dynamic SOCKS proxy with SSH listening on local port 1080:

ssh -v -N -D 1080 server

Then add the following to the list of VM options:

-Dhive.metastore.thrift.client.socks-proxy=localhost:1080

Running the CLI

Start the CLI to connect to the server and run SQL queries:

presto-cli/target/presto-cli-*-executable.jar

Run a query to see the nodes in the cluster:

SELECT * FROM system.runtime.nodes;

In the sample configuration, the Hive connector is mounted in the hive catalog, so you can run the following queries to show the tables in the Hive database default:

SHOW TABLES FROM hive.default;

Building the Documentation

To build the Presto docs, see the docs README.

Building the Presto Console

The Presto Console is composed of several React components and is written in JSX and ES6. This source code is stored in the presto-ui/ module. The compilation process generates browser-compatible javascript which is added as JAR resources during the maven build. When the resource JAR is included on the classpath of Presto coordinator, it will be able to serve the resources.

None of the Java code relies on the Presto UI project being compiled, so it is possible to exclude this UI when building Presto. Add the property -DskipUI to the maven command to disable building the ui maven module.

./mvnw clean install -DskipUI

You must have Node.js and Yarn installed to build the UI. When using Maven to build the project, Node and yarn are installed in the presto-ui/target folder. Add the node and yarn executables to the PATH environment variable.

To update Presto Console after making changes, run:

yarn --cwd presto-ui/src install

To simplify iteration, you can also run in watch mode, which automatically re-compiles when changes to source files are detected:

yarn --cwd presto-ui/src run watch

To iterate quickly, simply re-build the project in IntelliJ after packaging is complete. Project resources will be hot-reloaded and changes are reflected on browser refresh.

Presto native and Velox

Presto native is a C++ rewrite of Presto worker. Presto native uses Velox as its primary engine to run presto workloads.

Velox is a C++ database library which provides reusable, extensible, and high-performance data processing components.

Check out building instructions to get started.

Using development containers

The PrestoDB project provides support for development containers in its own repository. Please visit the presto-dev README for details.


Contributing!

Please refer to the contribution guidelines to get started.

Questions?

Please join our Slack channel and ask in #dev.

License

By contributing to Presto, you agree that your contributions will be licensed under the Apache License Version 2.0 (APLv2).

Extension points exported contracts — how you extend this code

ExpectedValueProvider (Interface)
An implementation of ExpectedValueProvider should hold the values and SymbolAliases needed to call T's constructor, a [96 …
presto-main-base/src/test/java/com/facebook/presto/sql/planner/assertions/ExpectedValueProvider.java
RedisFieldDecoder (Interface)
Format specific field decoder description. [47 implementers]
presto-redis/src/main/java/com/facebook/presto/redis/RedisFieldDecoder.java
HiveCluster (Interface)
A Hive cluster is a single logical installation of Hive. It might have multiple instances of the metastore service (for [8 …
presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/HiveCluster.java
ConnectorPlanOptimizer (Interface)
Given a PlanNode, return a transformed PlanNode. The given {@param maxSubplan} is a highest PlanNode in the query p [15 …
presto-spi/src/main/java/com/facebook/presto/spi/ConnectorPlanOptimizer.java
RowDecoder (Interface)
Implementations decode a row from bytes and add field value providers for all decodable columns. [15 implementers]
presto-record-decoder/src/main/java/com/facebook/presto/decoder/RowDecoder.java
PrestoSparkPageInput (Interface)
Implementation of this interface is expected to be thread safe [52 implementers]
presto-spark-base/src/main/java/com/facebook/presto/spark/execution/PrestoSparkPageInput.java
FixedWidthType (Interface)
FixedWidthType is a type that has a fixed size for every value. [23 implementers]
presto-common/src/main/java/com/facebook/presto/common/type/FixedWidthType.java
CustomSplitConverter (Interface)
Interface for Split specific implementation of conversion from Split -> customSplitInfo Map and back. [6 implementers]
presto-hive/src/main/java/com/facebook/presto/hive/util/CustomSplitConverter.java

Core symbols most depended-on inside this repo

of
called by 18554
presto-main-base/src/main/java/com/facebook/presto/operator/WorkProcessor.java
of
called by 13094
presto-orc/src/main/java/com/facebook/presto/orc/DwrfKeyProvider.java
assertFunction
called by 8117
presto-main-tests/src/main/java/com/facebook/presto/tests/operator/scalar/TestFunctions.java
get
called by 6970
presto-spi/src/main/java/com/facebook/presto/spi/NodeProvider.java
format
called by 5422
presto-iceberg/src/main/java/com/facebook/presto/iceberg/delete/DeleteFile.java
add
called by 4782
presto-spi/src/main/java/com/facebook/presto/spi/WarningCollector.java
build
called by 4744
presto-tests/src/main/java/com/facebook/presto/tests/ResultsSession.java
map
called by 4680
presto-main-base/src/main/java/com/facebook/presto/operator/WorkProcessor.java

Shape

Method 92,348
Class 11,865
Interface 853
Enum 470
Function 384

Languages

Java97%
TypeScript3%
Python1%

Modules by API surface

presto-ui/src/sql-parser/SqlBaseParser.js2,427 symbols
presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java522 symbols
presto-ui/src/sql-parser/SqlBaseListener.js488 symbols
presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestQueries.java466 symbols
presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataManagerStats.java343 symbols
presto-main-base/src/main/java/com/facebook/presto/SystemSessionProperties.java307 symbols
presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/Analysis.java272 symbols
presto-hive/src/main/java/com/facebook/presto/hive/HiveClientConfig.java247 symbols
presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java240 symbols
presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java231 symbols
presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java206 symbols
presto-common/src/main/java/com/facebook/presto/common/predicate/TupleDomainFilter.java200 symbols

Dependencies from manifests, versioned

${project.groupId}:presto-main-base
${project.groupId}:presto-main-tests
at.favre.lib:bcrypt0.10.2 · 1×
at.yawk.lz4:lz4-java1.10.2 · 1×
com.101tec:zkclient0.11 · 1×
com.amazon.redshift:redshift-jdbc422.2.7 · 1×
com.amazonaws:aws-java-sdk-core
com.amazonaws:aws-java-sdk-glue
com.amazonaws:aws-java-sdk-s3
com.amazonaws:aws-java-sdk-sts
com.clearspring.analytics:stream2.9.8 · 1×
com.datastax.cassandra:cassandra-driver-core3.11.5 · 1×

Datastores touched

(mysql)Database · 1 repos
(mongodb)Database · 1 repos
metastoreDatabase · 1 repos
hydraDatabase · 1 repos
testdbDatabase · 1 repos

For agents

$ claude mcp add presto \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact