From e6d6cb1bb8d2b5f4f361ea3630a483cbb489522f Mon Sep 17 00:00:00 2001 From: Hana Kessler <58595147+hanakslr@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:55:45 -0500 Subject: [PATCH] import trino docker setup from dbcrossbar This originally came from dbt-trino. Co-Authored-By: Eric Kidd <36963+emk@users.noreply.github.com> --- trino/.env | 5 + trino/.gitignore | 1 + trino/LICENSE.txt | 201 ++++++++++++++++++ trino/README.md | 5 + trino/docker-compose.yml | 88 ++++++++ .../trino/catalog/dbcrossbar.properties | 17 ++ trino/docker/trino/catalog/delta.properties | 13 ++ trino/docker/trino/catalog/hive.properties | 16 ++ trino/docker/trino/catalog/iceberg.properties | 12 ++ trino/docker/trino/catalog/memory.properties | 2 + .../trino/catalog/postgresql.properties | 4 + .../trino/etc/access-control.properties | 1 + trino/docker/trino/etc/config.properties | 4 + trino/docker/trino/etc/jvm.config | 13 ++ trino/docker/trino/etc/node.properties | 2 + 15 files changed, 384 insertions(+) create mode 100644 trino/.env create mode 100644 trino/.gitignore create mode 100644 trino/LICENSE.txt create mode 100644 trino/README.md create mode 100644 trino/docker-compose.yml create mode 100644 trino/docker/trino/catalog/dbcrossbar.properties create mode 100644 trino/docker/trino/catalog/delta.properties create mode 100644 trino/docker/trino/catalog/hive.properties create mode 100644 trino/docker/trino/catalog/iceberg.properties create mode 100644 trino/docker/trino/catalog/memory.properties create mode 100644 trino/docker/trino/catalog/postgresql.properties create mode 100644 trino/docker/trino/etc/access-control.properties create mode 100644 trino/docker/trino/etc/config.properties create mode 100644 trino/docker/trino/etc/jvm.config create mode 100644 trino/docker/trino/etc/node.properties diff --git a/trino/.env b/trino/.env new file mode 100644 index 0000000..0fb3535 --- /dev/null +++ b/trino/.env @@ -0,0 +1,5 @@ +export AWS_ENDPOINT_URL=http://localhost:9000 +# SECURITY: These are not real credentials. They're used locally +# for testing and dev with a local copy of MinIO, not AWS. +export AWS_ACCESS_KEY_ID=minio +export AWS_SECRET_ACCESS_KEY=minio123 diff --git a/trino/.gitignore b/trino/.gitignore new file mode 100644 index 0000000..e52ced2 --- /dev/null +++ b/trino/.gitignore @@ -0,0 +1 @@ +/trino diff --git a/trino/LICENSE.txt b/trino/LICENSE.txt new file mode 100644 index 0000000..25431b1 --- /dev/null +++ b/trino/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 Starburst Data, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/trino/README.md b/trino/README.md new file mode 100644 index 0000000..6fbb722 --- /dev/null +++ b/trino/README.md @@ -0,0 +1,5 @@ +# Trino Docker setup + +Original code copyright 2021 Starburst Data, Inc. + +This is a modified copy of [dbt-trino](https://github.com/starburstdata/dbt-trino)'s test environment, licensed under an [Apache 2 license](https://github.com/starburstdata/dbt-trino/blob/master/LICENSE.txt). This copy has been modified to work with newer versions of Trino. diff --git a/trino/docker-compose.yml b/trino/docker-compose.yml new file mode 100644 index 0000000..5b3ccf9 --- /dev/null +++ b/trino/docker-compose.yml @@ -0,0 +1,88 @@ +version: "3.9" +services: + trino: + ports: + - "8080:8080" + image: "trinodb/trino:460" + volumes: + - ./docker/trino/etc:/usr/lib/trino/etc:ro + - ./docker/trino/catalog:/etc/trino/catalog + + postgres: + ports: + - "5432:5432" + image: postgres:11 + container_name: postgres + environment: + POSTGRES_USER: dbt-trino + POSTGRES_PASSWORD: dbt-trino + + metastore_db: + image: postgres:11 + hostname: metastore_db + environment: + POSTGRES_USER: hive + POSTGRES_PASSWORD: hive + POSTGRES_DB: metastore + + hive-metastore: + hostname: hive-metastore + image: 'starburstdata/hive:3.1.2-e.18' + ports: + - '9083:9083' # Metastore Thrift + environment: + HIVE_METASTORE_DRIVER: org.postgresql.Driver + HIVE_METASTORE_JDBC_URL: jdbc:postgresql://metastore_db:5432/metastore + HIVE_METASTORE_USER: hive + HIVE_METASTORE_PASSWORD: hive + HIVE_METASTORE_WAREHOUSE_DIR: s3://datalake/ + S3_ENDPOINT: http://minio:9000 + S3_ACCESS_KEY: minio + S3_SECRET_KEY: minio123 + S3_PATH_STYLE_ACCESS: "true" + REGION: "" + GOOGLE_CLOUD_KEY_FILE_PATH: "" + AZURE_ADL_CLIENT_ID: "" + AZURE_ADL_CREDENTIAL: "" + AZURE_ADL_REFRESH_URL: "" + AZURE_ABFS_STORAGE_ACCOUNT: "" + AZURE_ABFS_ACCESS_KEY: "" + AZURE_WASB_STORAGE_ACCOUNT: "" + AZURE_ABFS_OAUTH: "" + AZURE_ABFS_OAUTH_TOKEN_PROVIDER: "" + AZURE_ABFS_OAUTH_CLIENT_ID: "" + AZURE_ABFS_OAUTH_SECRET: "" + AZURE_ABFS_OAUTH_ENDPOINT: "" + AZURE_WASB_ACCESS_KEY: "" + HIVE_METASTORE_USERS_IN_ADMIN_ROLE: "admin" + depends_on: + - metastore_db + + minio: + hostname: minio + image: 'minio/minio:RELEASE.2022-05-26T05-48-41Z' + container_name: minio + ports: + - '9000:9000' + - '9001:9001' + environment: + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minio123 + command: server /data --console-address ":9001" + + # This job will create the "datalake" bucket on Minio + mc-job: + image: 'minio/mc:RELEASE.2022-05-09T04-08-26Z' + entrypoint: | + /bin/bash -c " + sleep 5; + /usr/bin/mc config --quiet host add myminio http://minio:9000 minio minio123; + /usr/bin/mc mb --quiet myminio/datalake + " + depends_on: + - minio + +networks: + default: + name: trino-test + diff --git a/trino/docker/trino/catalog/dbcrossbar.properties b/trino/docker/trino/catalog/dbcrossbar.properties new file mode 100644 index 0000000..b0eca4f --- /dev/null +++ b/trino/docker/trino/catalog/dbcrossbar.properties @@ -0,0 +1,17 @@ +connector.name=hive +hive.metastore.uri=thrift://hive-metastore:9083 +fs.native-s3.enabled=true +s3.endpoint=http://minio:9000 +s3.region=us-east-1 +s3.path-style-access=true +s3.aws-access-key=minio +s3.aws-secret-key=minio123 +hive.metastore-cache-ttl=0s +hive.metastore-refresh-interval=5s +hive.metastore.thrift.client.connect-timeout=10s +hive.metastore.thrift.client.read-timeout=10s +hive.security=sql-standard + +# FARADAY - EMK +hive.non-managed-table-writes-enabled=true +hive.compression-codec=none diff --git a/trino/docker/trino/catalog/delta.properties b/trino/docker/trino/catalog/delta.properties new file mode 100644 index 0000000..86f0119 --- /dev/null +++ b/trino/docker/trino/catalog/delta.properties @@ -0,0 +1,13 @@ +connector.name=delta-lake +delta.enable-non-concurrent-writes=true +fs.native-s3.enabled=true +s3.endpoint=http://minio:9000 +s3.region=us-east-1 +s3.path-style-access=true +hive.metastore.uri=thrift://hive-metastore:9083 +s3.aws-access-key=minio +s3.aws-secret-key=minio123 +hive.metastore-cache-ttl=0s +hive.metastore-refresh-interval=5s +hive.metastore.thrift.client.connect-timeout=10s +hive.metastore.thrift.client.read-timeout=10s diff --git a/trino/docker/trino/catalog/hive.properties b/trino/docker/trino/catalog/hive.properties new file mode 100644 index 0000000..7dd9801 --- /dev/null +++ b/trino/docker/trino/catalog/hive.properties @@ -0,0 +1,16 @@ +connector.name=hive +hive.metastore.uri=thrift://hive-metastore:9083 +fs.native-s3.enabled=true +s3.endpoint=http://minio:9000 +s3.region=us-east-1 +s3.path-style-access=true +s3.aws-access-key=minio +s3.aws-secret-key=minio123 +hive.metastore-cache-ttl=0s +hive.metastore-refresh-interval=5s +hive.metastore.thrift.client.connect-timeout=10s +hive.metastore.thrift.client.read-timeout=10s +hive.security=sql-standard + +# FARADAY - EMK +hive.non-managed-table-writes-enabled=true diff --git a/trino/docker/trino/catalog/iceberg.properties b/trino/docker/trino/catalog/iceberg.properties new file mode 100644 index 0000000..cdb5557 --- /dev/null +++ b/trino/docker/trino/catalog/iceberg.properties @@ -0,0 +1,12 @@ +connector.name=iceberg +hive.metastore.uri=thrift://hive-metastore:9083 +fs.native-s3.enabled=true +s3.endpoint=http://minio:9000 +s3.region=us-east-1 +s3.path-style-access=true +s3.aws-access-key=minio +s3.aws-secret-key=minio123 +hive.metastore-cache-ttl=0s +hive.metastore-refresh-interval=5s +hive.metastore.thrift.client.connect-timeout=10s +hive.metastore.thrift.client.read-timeout=10s diff --git a/trino/docker/trino/catalog/memory.properties b/trino/docker/trino/catalog/memory.properties new file mode 100644 index 0000000..56b3b5e --- /dev/null +++ b/trino/docker/trino/catalog/memory.properties @@ -0,0 +1,2 @@ +connector.name=memory +memory.max-data-per-node=128MB diff --git a/trino/docker/trino/catalog/postgresql.properties b/trino/docker/trino/catalog/postgresql.properties new file mode 100644 index 0000000..90527b9 --- /dev/null +++ b/trino/docker/trino/catalog/postgresql.properties @@ -0,0 +1,4 @@ +connector.name=postgresql +connection-url=jdbc:postgresql://postgres:5432/dbt-trino +connection-user=dbt-trino +connection-password=dbt-trino diff --git a/trino/docker/trino/etc/access-control.properties b/trino/docker/trino/etc/access-control.properties new file mode 100644 index 0000000..bb7f9d7 --- /dev/null +++ b/trino/docker/trino/etc/access-control.properties @@ -0,0 +1 @@ +access-control.name=allow-all diff --git a/trino/docker/trino/etc/config.properties b/trino/docker/trino/etc/config.properties new file mode 100644 index 0000000..0b4b617 --- /dev/null +++ b/trino/docker/trino/etc/config.properties @@ -0,0 +1,4 @@ +coordinator=true +node-scheduler.include-coordinator=true +http-server.http.port=8080 +discovery.uri=http://localhost:8080 diff --git a/trino/docker/trino/etc/jvm.config b/trino/docker/trino/etc/jvm.config new file mode 100644 index 0000000..087fd09 --- /dev/null +++ b/trino/docker/trino/etc/jvm.config @@ -0,0 +1,13 @@ +-server +-XX:InitialRAMPercentage=80 +-XX:MaxRAMPercentage=80 +-XX:G1HeapRegionSize=32M +-XX:+ExplicitGCInvokesConcurrent +-XX:+HeapDumpOnOutOfMemoryError +-XX:+ExitOnOutOfMemoryError +-XX:-OmitStackTraceInFastThrow +-XX:ReservedCodeCacheSize=256M +-XX:PerMethodRecompilationCutoff=10000 +-XX:PerBytecodeRecompilationCutoff=10000 +-Djdk.attach.allowAttachSelf=true +-Djdk.nio.maxCachedBufferSize=2000000 diff --git a/trino/docker/trino/etc/node.properties b/trino/docker/trino/etc/node.properties new file mode 100644 index 0000000..5b02ff7 --- /dev/null +++ b/trino/docker/trino/etc/node.properties @@ -0,0 +1,2 @@ +node.environment=docker +node.data-dir=/data/trino