class NessieNativeCatalogClient
Catalog client for Nessie over its NATIVE /api/v2 trees API — the access model Iceberg’s own NessieCatalog uses (client-side warehouse + authentication.type). Selected when a Nessie catalog has nessie_api_mode == “native”.
The response shapes differ from Iceberg REST: * GET /api/v2/trees/{ref}/entries returns a flat “entries” array (with “type”, “name.elements”, “contentId”) and a “token” for pagination, not nested “namespaces”/“identifiers” with “next-page-token”. * GET /api/v2/trees/{ref}/contents/{path} returns the Iceberg table Content (metadataLocation), not the full TableMetadata — so the summary metrics stay nil until a maintenance run enriches them via Trino.
Public Instance Methods
Source
# File app/services/nessie_native_catalog_client.rb, line 28 def base_url "#{catalog.endpoint}#{mount_prefix}" end
The native API base is {endpoint}/api/v2 — no /v1/{rest_prefix} segment.
@return [String] the base URL for native API calls
Source
# File app/services/nessie_native_catalog_client.rb, line 23 def config_warehouse = nil
The native API has no /v1/config warehouse discovery — the ref and warehouse are client-side settings on the catalog.
@return [nil]
Source
# File app/services/nessie_native_catalog_client.rb, line 15 def mount_prefix "/api/v2" end
@return [String] the mount prefix before /v1 (native API has no /v1)
Source
# File app/services/nessie_native_catalog_client.rb, line 37 def namespaces # The root ("") is listed first so the sync visits tables that live at the # repository root, which Nessie permits. Without it those tables were # unreachable: the sync only ever calls tables_in for a discovered # namespace, so a repository keeping tables at the root imported part of # its catalog with no error to say anything was missed. [ "" ] + collect_namespaces(nil, 0) end
Walks the tree entries, one flat request per level. Every entry carries a dotted name path; NAMESPACE entries below the current depth become the next level, so the recursion matches Iceberg REST semantics.
@return [Array<String>] all descendant namespace paths
# File app/services/nessie_native_catalog_client.rb, line 86 def table_metadata(namespace, table) # A root table's content key is the bare table name - prefixing a blank # namespace would send a leading dot and miss the content. path = namespace.presence ? "#{namespace}.#{table}" : table content = get("#{base_url}/trees/#{ERB::Util.url_encode(ref)}/contents/#{path}") { "metadata" => { "table-uuid" => content["contentId"], "location" => content.dig("metadata", "metadataLocation") || content["metadataLocation"], "snapshots" => [], "current-snapshot-id" => nil } } end
Fetches the Iceberg table Content for a table. The native API returns the Content object (metadataLocation), not the full TableMetadata payload the Iceberg REST surface serves — the health summary metrics are therefore nil until maintenance enriches them.
@param namespace [String] the dotted namespace path @param table [String] the table name @return [Hash] a { “metadata” => … }-shaped payload the sync can read
Source
# File app/services/nessie_native_catalog_client.rb, line 57 def tables_in(namespace) root = namespace.blank? entries(root ? "" : namespace).filter_map do |entry| next unless entry["type"] == "ICEBERG_TABLE" elements = Array(entry.dig("name", "elements")) next if elements.empty? if root # A root table is exactly one element deep; anything deeper belongs to # a namespace and is listed by that namespace's own call. next unless elements.size == 1 else next unless dotted_name(entry).start_with?("#{namespace}.") end elements.last end.compact end
Lists the Iceberg table names directly under a namespace.
A blank namespace lists the tables at the repository ROOT, which Nessie permits. Those entries have a single-element name and no namespace, so the filter is entry.namespace == '' and the prefix guard cannot apply.
ICEBERG_VIEW entries are deliberately excluded: the maintenance operations do not apply to views.
@param namespace [String] the dotted namespace path (“” for the root) @return [Array<String>] table names in the namespace