class Catalog
Constants
- BLOCKED_HOSTS
- BLOCKED_PREFIXES
- CATALOG_TYPES
- NESSIE_API_MODES
-
How a Nessie catalog is addressed. “rest” uses Nessie’s Iceberg REST surface (/iceberg/v1, server-side default warehouse); “native” uses the native /api/v2 API with a client-supplied warehouse and authentication.type— the model Iceberg’s own NessieCatalog implements.
- NESSIE_REF_PATTERN
-
Which Nessie ref (branch/tag) this catalog reads. Only meaningful for catalog_type “nessie”; when blank the server default branch answers, and a Trino pointed elsewhere diverges silently - names match, numbers don’t.
Empirical (Nessie 0.108.4): the ref IS the Iceberg REST prefix returned by /v1/config (“prefix-pattern”: “{ref}|{warehouse}”); an unknown ref answers HTTP 400 on any /v1/{ref}/… call.
- PROPERTIES_SECRET_KEYS
-
properties is CONFIGURATION only (warehouse hints and the like). Secrets have exactly one home: CatalogCredential.secret, encrypted. Rejecting them here keeps the plaintext JSON column from ever becoming a side channel.
- S3_AUTH_TYPES
- TRINO_NAME_MAX
- TRINO_NAME_PATTERN
-
Mirrors CatalogRow.java v0.2.1 and the trino_catalog_registry CHECK. Any drift here makes the INSERT fail with a constraint violation whose message does not help whoever registered the catalog.
- TRINO_RESERVED
- VERIFY_NAMESPACE_SAMPLE
-
Namespaces sampled when counting tables for the verification message. Verification is interactive, so the count is a signal that the listing works at all - not an inventory. A catalog with more namespaces than this stops early rather than making the operator wait on a full walk.
Public Instance Methods
# File app/models/catalog.rb, line 64 def derived_trino_catalog_name slug = name.to_s.downcase .gsub(/[^a-z0-9_]/, "_") .gsub(/_+/, "_") .gsub(/\A_+|_+\z/, "") # Must start with a letter: prefix when it starts with a digit or is empty. slug = "cat_#{slug}" unless slug.match?(/\A[a-z]/) # Trino reserved: prefix instead of failing, so registration does not get # stuck on a name the person chose without knowing the restriction. slug = "cat_#{slug}" if TRINO_RESERVED.include?(slug) slug.first(TRINO_NAME_MAX) end
Derives a valid Trino catalog name from the record name, slugifying it and prefixing names that start with a digit or collide with a reserved word. @return [String] the derived, truncated catalog name
Source
# File app/models/catalog.rb, line 107 def resolve_s3_credentials case s3_authentication_type when "none" {} when "static" { "s3.aws-access-key" => s3_access_key, "s3.aws-secret-key" => s3_secret_key } when "sts" sts_client = Aws::STS::Client.new( access_key_id: s3_access_key, secret_access_key: s3_secret_key, region: s3_region.presence || "us-east-1", endpoint: s3_endpoint.presence ) resp = sts_client.assume_role( role_arn: s3_role_arn, role_session_name: "deepdiver-#{trino_catalog_name}", external_id: s3_external_id.presence ) { "s3.aws-access-key" => resp.credentials.access_key_id, "s3.aws-secret-key" => resp.credentials.secret_access_key, "s3.aws-session-token" => resp.credentials.session_token } else # s3_authentication_type is validated against S3_AUTH_TYPES with a # non-null default, so this is unreachable in practice - but callers # (TrinoCatalogProjection) do `props.merge!(resolve_s3_credentials)`, # and merge!(nil) raises TypeError. An empty hash is the safe no-op. {} end end
Returns the S3 connector properties for Trino. For “none” returns an empty hash; for “static” the stored access key and secret; for “sts” calls AssumeRole and returns the temporary credentials.
@return [Hash{String => String}] properties to merge into Trino connector config
Source
# File app/models/catalog.rb, line 82 def to_s name end
Human-readable representation of the catalog. @return [String] the catalog name
Source
# File app/models/catalog.rb, line 57 def trino_catalog_name trino_catalog_name_override.presence || derived_trino_catalog_name end
Name of the catalog inside Trino. Derived from the record name, because the application provisions Trino itself. The override exists for when the name is not a valid identifier or collides.
Source
# File app/models/catalog.rb, line 87 def verify_connection! client = CatalogClientFactory.for(self) namespaces = client.namespaces # Count the tables too. Namespace discovery succeeding while the table # listing is broken reported a verified connection that then imported # nothing, and "N namespaces, 0 tables" is what makes that visible at the # moment an operator is deciding whether the catalog works. table_count = count_tables(client, namespaces) catalog_credential&.update!(verified_at: Time.current, verification_error: nil) { ok: true, namespace_count: namespaces.size, table_count: table_count } rescue StandardError => e catalog_credential&.update!(verified_at: Time.current, verification_error: e.message) { ok: false, error: e.message } end
Makes a real call and returns what happened, for the “Test” button.