Trino Server

Business Data Publisher

Platform:

Channel Revision Published Runs on
latest/stable 39 09 Dec 2024
Ubuntu 22.04
latest/beta 33 03 Oct 2024
Ubuntu 22.04
latest/edge 78 12 Oct 2026
Ubuntu 22.04
juju deploy trino-k8s

charms.trino_k8s.v0.trino_catalog

Library for the trino_catalog relation.

This library provides the TrinoCatalogProvider and TrinoCatalogRequirer classes that handle the provider and the requirer sides of the trino_catalog interface.

A requirer can be related to several Trino applications. get_trino_info() and get_credentials() without arguments read the first relation only. To read every relation, use the per-relation accessors, which skip (and log) relations that are incomplete, malformed or whose secret cannot be read:

requirer = TrinoCatalogRequirer(self, relation_name="trino-catalog")

info_by_relation = requirer.get_all_trino_info()
credentials_by_relation = requirer.get_all_credentials()
for relation_id, info in info_by_relation.items():
    credentials = credentials_by_relation.get(relation_id)
    if not credentials:
        continue
    username, password = credentials
    connect(info["remote_app"], info["trino_url"], username, password)

class TrinoCatalog

Description

Represents a Trino catalog. None

Methods

TrinoCatalog. __init__( self , name: str , connector: str , description: str )

Initialize a TrinoCatalog.

Arguments

name

Catalog name (e.g., "marketing", "sales")

connector

Optional connector type (e.g., "postgresql", "mysql", "bigquery")

description

Optional description of the catalog

TrinoCatalog. to_dict( self )

Convert to dictionary for serialization.

Returns

Dictionary with name, connector, and description keys

TrinoCatalog. from_dict( cls , data: dict )

Create TrinoCatalog from dictionary.

Arguments

data

Dictionary with name, optional connector, and optional description

Returns

TrinoCatalog instance

TrinoCatalog. __repr__( self )

Return a string representation for debugging.

Returns

String representation of the TrinoCatalog object.

TrinoCatalog. __eq__( self , other )

Compare two catalogs for equality.

Arguments

other

Object to compare with.

Returns

True if catalogs are equal, False otherwise.

class TrinoCatalogProvider

Provider side of the trino_catalog relation.

Description

This library handles the relation lifecycle and data updates. The charm is responsible for providing the actual data (url, catalogs, secret).

Methods

TrinoCatalogProvider. __init__( self , charm: CharmBase , relation_name: str )

Initialize the TrinoCatalogProvider.

Arguments

charm

The charm instance.

relation_name

Name of the relation.

TrinoCatalogProvider. update_relation_data( self , relation , trino_url: str , trino_catalogs , trino_credentials_secret_id: str )

Update relation data for a specific relation.

Arguments

relation

The relation to update

trino_url

Trino URL (e.g., "trino.example.com:443")

trino_catalogs

List of TrinoCatalog objects

trino_credentials_secret_id

Juju secret ID containing Trino users

Returns

True if successful, False otherwise

class TrinoCatalogRequirer

Description

Requirer side of the trino_catalog relation. None

Methods

TrinoCatalogRequirer. __init__( self , charm: CharmBase , relation_name: str )

Initialize the TrinoCatalogRequirer.

Arguments

charm

The charm instance.

relation_name

Name of the relation.

TrinoCatalogRequirer. get_trino_info( self , relation )

Get current Trino connection information.

Arguments

relation

The relation to read. Defaults to the first relation, in which case the result only has the three keys below. When a relation is given, the result also has relation_id and remote_app.

Returns

Dictionary with trino_url, trino_catalogs (List[TrinoCatalog]), and trino_credentials_secret_id, or None if not available.

TrinoCatalogRequirer. get_all_trino_info( self )

Get Trino connection information for every complete relation.

Returns

Mapping of relation ID to a dictionary with trino_url, trino_catalogs (List[TrinoCatalog]), trino_credentials_secret_id, relation_id and remote_app. Incomplete or malformed relations are left out.

TrinoCatalogRequirer. get_credentials( self , relation )

Get Trino credentials from the per-relation secret.

Arguments

relation

The relation to read. Defaults to the first relation.

Returns

Tuple of (username, password) or None if not available.

TrinoCatalogRequirer. get_all_credentials( self )

Get Trino credentials for every relation that has readable ones.

Returns

Mapping of relation ID to (username, password).

Description

Relations with incomplete data, an unreadable secret or missing credential fields are logged and left out.