Package: dbt-presto
dbt-prestoDocumentationFor more information on using Presto with dbt, consult the dbt documentation:Presto profileInstallationThis plugin can be installed via pip:$ pip install dbt-prestoConfiguring your profileA dbt profile can be configured to run against Presto using the following configuration:OptionDescriptionRequired?ExamplemethodThe Presto authentication method to useOptional (default isnone)noneorkerberosuserUsername for authenticationRequireddrewpasswordPassword for authenticationOptional (required ifmethodisldaporkerberos)noneorabc123http_headersHTTP Headers to send alongside requests to Presto, specified as a yaml dictionary of (header, value) pairs.OptionalX-Presto-Routing-Group: my-clusterhttp_schemeThe HTTP scheme to use for requests to PrestoOptional (default ishttp, orhttpsformethod: kerberosandmethod: ldap)httpsorhttpdatabaseSpecify the database to build models intoRequiredanalyticsschemaSpecify the schema to build models into. Note: it is not recommended to use upper or mixed case schema namesRequireddbt_drewhostThe hostname to connect toRequired127.0.0.1portThe port to connect to the host onRequired8080threadsHow many threads dbt should useOptional (default is1)8Example profiles.yml entry:my-presto-db:
  target: dev
  outputs:
    dev:
      type: presto
      user: drew
      host: 127.0.0.1
      port: 8080
      database: analytics
      schema: dbt_drew
      threads: 8Usage NotesSupported FunctionalityDue to the nature of Presto, not all core dbt functionality is supported.
The following features of dbt are not implemented on Presto:ArchivalIncremental modelsAlso, note that upper or mixed case schema names will cause catalog queries to fail. Please only use lower case schema names with this adapter.If you are interested in helping to add support for this functionality in dbt on Presto, pleaseopen an issue!Required configurationdbt fundamentally works by dropping and creating tables and views in databases.
As such, the following Presto configs must be set for dbt to work properly on Presto:hive.metastore-cache-ttl=0s
hive.metastore-refresh-interval = 5s
hive.allow-drop-table=true
hive.allow-rename-table=trueUse table properties to configure connector specificsTrino/Presto connectors use table properties to configure connector specifics.Check the Presto/Trino connector documentation for more information.{{
  config(
    materialized='table',
    properties={
      "format": "'PARQUET'",
      "partitioning": "ARRAY['bucket(id, 2)']",
    }
  )
}}Reporting bugs and contributing codeWant to report a bug or request a feature? Let us know onSlack, or openan issue.Running testsBuild dbt container locally:./docker/dbt/build.shRun a Presto server locally:./docker/init.bashIf you see errors while about "inconsistent state" while bringing up presto,
you may need to drop and re-create thepublicschema in the hive metastore:# Example error

Initialization script hive-schema-2.3.0.postgres.sql
Error: ERROR: relation "BUCKETING_COLS" already exists (state=42P07,code=0)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
Use --verbose for detailed stacktrace.
*** schemaTool failed ***Solution:Drop (or rename) the public schema to allow the init script to recreate the metastore from scratch.Only run this against a test Presto deployment. Do not run this in production!-- run this against the hive metastore (port forwarded to 10005 by default)-- DO NOT RUN THIS IN PRODUCTION!dropschemapubliccascade;createschemapublic;You probably should be slightly less reckless than this.Run tests against Presto:./docker/run_tests.bashRun the locally-built docker image (from docker/dbt/build.sh):export DBT_PROJECT_DIR=$HOME/... # wherever the dbt project you want to run is
docker run -it --mount "type=bind,source=$HOME/.dbt/,target=/home/dbt_user/.dbt" --mount="type=bind,source=$DBT_PROJECT_DIR,target=/usr/app" --network dbt-net dbt-presto /bin/bashCode of ConductEveryone interacting in the dbt project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow thePyPA Code of Conduct.