class CatalogClient
Base Iceberg REST Catalog client. Talks to Polaris/Nessie over Net::HTTP and exposes a narrow interface the sync job needs. Transport is injected, so tests never hit the network.
Constants
- MAX_NAMESPACE_DEPTH
- NAMESPACE_SEPARATOR
Attributes
Public Class Methods
# File app/services/catalog_client.rb, line 16 def initialize(catalog, transport: HttpTransport.new) @catalog = catalog @transport = transport end
Creates a client bound to a catalog with an injectable transport.
@param catalog [Catalog] the catalog the client talks to @param transport [HttpTransport] the HTTP transport to use (injected for tests)
Public Instance Methods
Source
# File app/services/catalog_client.rb, line 52 def config_url url = +"#{catalog.endpoint}#{mount_prefix}/v1/config" url << "?warehouse=#{CGI.escape(config_warehouse)}" if config_warehouse.present? url.to_s end
Absolute URL of the /v1/config discovery call, warehouse included when the provider names its warehouses.
@return [String]
Source
# File app/services/catalog_client.rb, line 24 def namespaces collect_namespaces(nil, 0) end
Walks the namespace tree recursively. The REST API only returns the direct children of a namespace, so without this recursion anything nested stays invisible to the sync.
# File app/services/catalog_client.rb, line 44 def table_metadata(namespace, table) get("#{base_url}/namespaces/#{encode_namespace(namespace)}/tables/#{ERB::Util.url_encode(table)}") end
Fetches the Iceberg REST TableMetadata for a table.
@param namespace [String] the dotted namespace path @param table [String] the table name @return [Hash] the parsed JSON response body
Source
# File app/services/catalog_client.rb, line 32 def tables_in(namespace) path = "/namespaces/#{encode_namespace(namespace)}/tables" paginated_get(path).flat_map do |body| (body["identifiers"] || body["tables"] || []).map { |entry| table_name(entry) } end end
Lists the table names directly under a namespace.
@param namespace [String] the dotted namespace path @return [Array<String>] table names in the namespace