Lakehouse - Connecting your own tools
Find out how to query and write the tables of your Lakehouse from Python with the Trino client and PyIceberg, and read them from DuckDB
Lakehouse is in alpha. It is only available to the accounts invited to the alpha programme, and its features, interface and API may change.
Objective
The tables of a Lakehouse are open Apache Iceberg tables. Besides the data console, you can use them from your own tools, through the SQL endpoint or the Iceberg REST catalog of the Lakehouse.
This guide explains how to connect the Python Trino client, PyIceberg and DuckDB to your Lakehouse.
Requirements
- A Lakehouse with at least one catalog and one schema. See Lakehouse - Getting started.
- A user with a role that gives access to the catalog, and a credential of this user. For PyIceberg and DuckDB, the credential must include an S31 access key. See Lakehouse - Managing access to your data.
- Python 3.9 or later for the Python examples.
Instructions
Step 1 - Gathering the connection values
The environment file you download when you create a credential holds every value the examples need. Except for the client ID, the client secret and the S3 keys, you can also find the endpoints and the SQL catalog names in the Connection details section of the Overview tab of the Lakehouse, and the realm in the same tab.
The SQL endpoint exposes each catalog under a SQL catalog name that is longer than the catalog name. A table is addressed as <sql_catalog>.<schema>.<table>.
Step 2 - Querying with the Python Trino client
The SQL endpoint accepts the client ID as user name and the client secret as password.
The privileges of the user apply: a user with the Data Viewer role can read, but any INSERT, UPDATE or CREATE TABLE is refused.
Step 3 - Reading and writing with PyIceberg
PyIceberg connects to the Iceberg REST catalog and reads or writes the data files directly in the bucket, with the S3 access key of the credential. The example below creates a table in the raw schema: the user needs a role that can create tables, such as Data Editor.
A table written with PyIceberg is immediately visible through the SQL endpoint and in the data console, and the other way round.
The Iceberg REST catalog does not hand out S3 credentials: PyIceberg and DuckDB need the S3 access key of the credential to read or write the data files.
Step 4 - Reading with DuckDB
DuckDB reads Iceberg tables through its iceberg extension. Three secrets are needed: one adds the realm header to the catalog requests, one holds the credential, and one holds the S3 access key.
In the S3 secret, replace s3.eu-west-par.io.cloud.ovh.net and eu-west-par with your <s3_endpoint> and <s3_region>, giving the endpoint host without https://.
Go further
Lakehouse - Managing access to your data
Lakehouse - Using a dedicated Compute Pool
Join our community of users.
1: S3 is a trademark of Amazon Technologies, Inc. OVHcloud's service is not sponsored by, endorsed by, or otherwise affiliated with Amazon Technologies, Inc.