Defining Cloudera Lakehouse Optimizer resources using REST APIs

When you use REST APIs to create or define a Cloudera Lakehouse Optimizer policy, use the default policy called "ClouderaAdaptive" as-is, or create a new policy. When you create a new policy or override an existing policy, you define the policy in a new JEXL file, alternatively add the required constants in a new JSON file, and then upload the resources.

Perform the following steps to create a new policy or to override an existing policy by defining the policy in the new JEXL file. Alternatively you can add the constants in the new JSON file.

Each policy has a unique name. Set an optional description in the JSON constants file. Enable one or more of the following Iceberg maintenance actions in the JEXL script and JSON constants, and adjust the parameters for each action:

  • Data file compaction (rewriteDataFiles)
  • Orphan file removal (deleteOrphanFiles)
  • Positional delete rewrite (rewritePositionDelete)
  • Snapshot expiration (expireSnapshot)
  • Manifest rewrite (rewriteManifest)

For parameter details, see JSON file constants.

  1. Create the JEXL file, and optionally the JSON file. You can use the default policy resources as a template to create the files, or you can create the files from scratch.
    For more information about the JEXL file and JSON file, see What are Cloudera Lakehouse Optimizer policy resources and JSON file.
  2. Upload the resources using the PUT /policies/resource API.
    Use the PATCH /policies/resource API to upload an updated policy resource.
    export BASE="<CLO endpoint>/clo/api/v1"
    export TOKEN="<paste token here>"
    curl -sk -X PUT -H "Authorization: Bearer $TOKEN" \
      "$BASE/policies/resource?uri=<encoded-resource-uri>" \
      -F "resource=@<path-to-resource-file>"

    To construct a URI to fetch, upload, and update policy resources, see URI to fetch, upload, and update policy resources.