Creating catalogs, namespaces, and tables on Cloudera Harmony Catalog

Set up catalogs, namespaces, and tables on a deployed Cloudera Harmony Catalog instance using the CLI and REST APIs.

When you spin up Cloudera Harmony Catalog for the first time, the service already creates a default catalog from Default catalog name on the Engine Settings tab during deployment. See step 8a in Configuring Cloudera Harmony Catalog on Anywhere Cloud. Use this procedure to create additional catalogs and, optionally, namespaces and tables through the CLI.

Deployment creates Ranger policies on the default catalog so consumers can use that catalog without creating another one. If you use this procedure to create additional catalogs, configure catalog-create and catalog-list policies for your user first. Cloudera Harmony Catalog does not create bootstrap policies for connected engines.

Before you begin, ensure the following requirements are met:

  • A Cloudera Harmony Catalog instance in Running status. For CATALOG_API, see Accessing Cloudera Harmony Catalog. For Knox SSO and CONSOLE_KNOX, see Authenticating to Cloudera Harmony Catalog REST APIs with Knox.
  • Your account can authenticate through Knox SSO. To create additional catalogs through the management API, you need catalog-create and catalog-list on the Harmony Catalog Ranger service. See Creating Ranger policies for additional catalogs. To create namespaces or tables in the steps below, you also need namespace and table permissions on the target catalog in Ranger—a catalog-only policy does not authorize those operations. Grant namespace and table access before you run those steps.
  • A storage bucket name for managed catalog storage, from the deployment Storage configuration or your administrator.
  1. Authenticate with Knox SSO.

    Complete the Knox OBO step and set HJWT as described in Authenticating to Cloudera Harmony Catalog REST APIs with Knox.

  2. Find the storage bucket the catalog will use.

    Cloudera Harmony Catalog catalogs are managed catalogs: storage is auto-attached from a bucket your environment already has access to. You do not supply credentials or paths yourself. Use the bucket name from the deployment storage configuration, or ask your administrator.

    At this release, you can create only INTERNAL catalogs. Storage is managed by Cloudera Anywhere Cloud Storage, which connects to Amazon S3, Google Cloud Storage buckets, and Azure Blob storage.

  3. Create the catalog.

    If you plan to use Cloudera Data Engineering or Cloudera Lakehouse Engine with the new catalog, use a catalog name that contains only letters and digits. Do not use underscores or hyphens in the name. The management API accepts other characters, but those engines require this naming convention.

    curl -sk -b "hadoop-jwt=${HJWT}" \
      -H "Content-Type: application/json" \
      -X POST "${CATALOG_API}/api/management/v1/catalogs" \
      -d '{
        "catalog": {
          "type": "INTERNAL",
          "name": "harmonycatalog",
          "properties": {
            "harmony-catalog.storage.proxinator.bucket": "<storage_bucket_name>"
          }
        }
      }'
    Table 1. Expected responses
    HTTP code Meaning
    201 Catalog created.
    409 A catalog with that name already exists.
    400 Bad request: usually a missing or wrong harmony-catalog.storage.proxinator.bucket property.
    403 Your account is not entitled to create catalogs on this service.
  4. Create a namespace.

    In most cases, creating a namespace and table should be done through engines, such as Cloudera Data Engineering or Cloudera Lakehouse Engine. It is also possible to use the Iceberg REST Catalog API to interact with Cloudera Harmony Catalog. See the Iceberg REST Catalog specification.

    A table must live in a namespace, so create one first.

    curl -sk -b "hadoop-jwt=${HJWT}" \
      -H "Content-Type: application/json" \
      -X POST "${CATALOG_API}/api/catalog/v1/harmonycatalog/namespaces" \
      -d '{
        "namespace": ["sales"],
        "properties": {"owner": "data-eng"}
      }'
    • 200: Namespace created.
    • 409: A namespace with that name already exists.
    • 404: The catalog does not exist (check the catalog name in the URL).
    • 403: Your account is not entitled to create namespaces in this catalog.

    For a nested namespace such as sales.emea, send "namespace": ["sales","emea"]. The parent (sales) must already exist.

    Verify:

    curl -sk -b "hadoop-jwt=${HJWT}" \
      "${CATALOG_API}/api/catalog/v1/harmonycatalog/namespaces"
  5. Create a table.
    curl -sk -b "hadoop-jwt=${HJWT}" \
      -H "Content-Type: application/json" \
      -X POST "${CATALOG_API}/api/catalog/v1/harmonycatalog/namespaces/sales/tables" \
      -d '{
        "name": "orders",
        "schema": {
          "type": "struct",
          "schema-id": 0,
          "fields": [
            {"id": 1, "name": "order_id", "required": true,  "type": "long"},
            {"id": 2, "name": "customer", "required": false, "type": "string"},
            {"id": 3, "name": "amount",   "required": false, "type": "double"},
            {"id": 4, "name": "order_ts", "required": false, "type": "timestamp"}
          ]
        },
        "properties": {"comment": "orders table"}
      }'

    The server assigns the table location under the catalog's storage. Do not send a location.

    To make a partitioned and sorted table, add these two fields to the same body:

    "partition-spec": {
      "spec-id": 0,
      "fields": [
        {"source-id": 4, "field-id": 1000, "name": "order_day", "transform": "day"}
      ]
    },
    "write-order": {
      "order-id": 1,
      "fields": [
        {"source-id": 1, "transform": "identity", "direction": "asc", "null-order": "nulls-first"}
      ]
    }

    Here source-id is the id of a column in the schema.

    • 200: Table created. The response is the full table metadata.
    • 409: A table with that name already exists.
    • 404: The catalog or namespace does not exist.
    • 403: Your account is not entitled to create tables in this namespace.
    • 500 or storage error: The service cannot write to its storage. Ask the administrator to check the service's storage write access.

    Verify:

    curl -sk -b "hadoop-jwt=${HJWT}" \
      "${CATALOG_API}/api/catalog/v1/harmonycatalog/namespaces/sales/tables"
    curl -sk -b "hadoop-jwt=${HJWT}" \
      "${CATALOG_API}/api/catalog/v1/harmonycatalog/namespaces/sales/tables/orders"
  6. Verify the catalog.
    curl -sk -b "hadoop-jwt=${HJWT}" "${CATALOG_API}/api/management/v1/catalogs/harmonycatalog"
    You should get back the catalog's JSON definition, including the storage location the server assigned.

When you enable Mirror catalog metadata to Unified Data Fabric during deployment, catalog metadata appears in the Cloudera Unified Data Fabric UI. To find catalogs and tables, see Finding and understanding assets.