-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Add Apache Trino to R2 Data Catalog examples #24945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5daa0a5
Adding trino.mdx to the R2 Data Catalog examples
Marcinthecloud 0a0af5f
Merge branch 'production' of https://github.com/Marcinthecloud/cloudf…
Marcinthecloud 2d66b29
Apply suggestions from code review
Oxyjun e3410da
Apply suggestions from code review
Oxyjun 5259089
simplified trino.mdx
Marcinthecloud 1c0b559
update trino.mdx with steps
Marcinthecloud aa0b17a
moved text out of code block
Marcinthecloud a480329
fixed markdown typo in trino.mdx
Marcinthecloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/content/docs/r2/data-catalog/config-examples/trino.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| title: Apache Trino | ||
| pcx_content_type: example | ||
| --- | ||
|
|
||
| import { Steps } from "~/components"; | ||
|
|
||
| Below is an example of using [Apache Trino](https://trino.io/) to connect to R2 Data Catalog. For more information on connecting to R2 Data Catalog with Trino, refer to [Trino documentation](https://trino.io/docs/current/connector/iceberg.html). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Sign up for a [Cloudflare account](https://dash.cloudflare.com/sign-up/workers-and-pages). | ||
| - [Create an R2 bucket](/r2/buckets/create-buckets/) and [enable the data catalog](/r2/data-catalog/manage-catalogs/#enable-r2-data-catalog-on-a-bucket). | ||
| - [Create an R2 API token, key, and secret](/r2/api/tokens/) with both [R2 and data catalog permissions](/r2/api/tokens/#permissions). | ||
| - Install [Docker](https://docs.docker.com/get-docker/) to run the Trino container. | ||
|
|
||
| ## Setup | ||
|
|
||
| Create a configuration file for your R2 Data Catalog connection: | ||
|
|
||
| ```properties | ||
| # r2.properties | ||
| connector.name=iceberg | ||
|
|
||
| # R2 Configuration | ||
| fs.native-s3.enabled=true | ||
| s3.region=auto | ||
| s3.aws-access-key=<Your R2 access key> | ||
| s3.aws-secret-key=<Your R2 secret> | ||
| s3.endpoint=<Your R2 endpoint> | ||
| s3.path-style-access=true | ||
|
|
||
| # R2 Data Catalog Configuration | ||
| iceberg.catalog.type=rest | ||
| iceberg.rest-catalog.uri=<Your R2 Data Catalog URI> | ||
| iceberg.rest-catalog.warehouse=<Your R2 Data Catalog warehouse> | ||
| iceberg.rest-catalog.security=OAUTH2 | ||
| iceberg.rest-catalog.oauth2.token=<Your R2 authentication token> | ||
| ``` | ||
|
|
||
| ## Example usage | ||
|
|
||
| <Steps> | ||
| 1. Start Trino with the R2 catalog configuration: | ||
|
|
||
| ```bash | ||
| # Create a local directory for the catalog configuration | ||
| mkdir -p trino-catalog | ||
|
|
||
| # Place your r2.properties file in the catalog directory | ||
| cp r2.properties trino-catalog/ | ||
|
|
||
| # Run Trino with the catalog configuration | ||
| docker run -d \ | ||
| --name trino-r2 \ | ||
| -p 8080:8080 \ | ||
| -v $(pwd)/trino-catalog:/etc/trino/catalog \ | ||
| trinodb/trino:latest | ||
| ``` | ||
Oxyjun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 2. Connect to Trino and query your R2 Data Catalog: | ||
|
|
||
| ```bash | ||
| # Connect to the Trino CLI | ||
| docker exec -it trino-r2 trino | ||
| ``` | ||
|
|
||
| 3. In the Trino CLI, run the following commands: | ||
|
|
||
| ```sql | ||
| -- Show all schemas in the R2 catalog | ||
| SHOW SCHEMAS IN r2; | ||
|
|
||
| -- Show all schemas in the R2 catalog | ||
| CREATE SCHEMA r2.example_schema | ||
|
|
||
| -- Create a table with some values in it | ||
| CREATE TABLE r2.example_schema.yearly_clicks ( | ||
| year, | ||
| clicks | ||
| ) | ||
| WITH ( | ||
| partitioning = ARRAY['year'] | ||
| ) | ||
| AS VALUES | ||
| (2021, 10000), | ||
| (2022, 20000); | ||
|
|
||
| -- Show tables in a specific schema | ||
| SHOW TABLES IN r2.example_schema; | ||
|
|
||
| -- Query your Iceberg table | ||
| SELECT * FROM r2.example_schema.yearly_clicks; | ||
| ``` | ||
| </Steps> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.