Using Cloudera SQL Stream Builder REST API

Use curl to call the Cloudera SQL Stream Builder (SSB) REST API: list your projects, create a job, start it, and stop it.

  • You have the hadoop-jwt cookie of a session. For more information, see Programmatic API access.
  • You have the ID of the project that you want to use. For more information, see Finding project IDs.
  • The tables that the job uses exist in the project.

Jobs that you start through the REST API run only in application mode, in a Flink cluster of their own. If the request does not contain a checkpoint_config object, checkpointing is off for the job, and the job does not restart after a failure. Sinks that commit their data when a checkpoint completes, such as the Iceberg and Filesystem connectors, write no data without a checkpoint_config object.

  1. Set environment variables for the SSB host, the session cookie, and the project ID.
    export SSB_URL="https://<instance-name>-ssb-sse.<domain>"
    export HADOOP_JWT="<hadoop-jwt-cookie-value>"
    export PROJECT_ID="<project-id>"
  2. List the projects that you have access to.
    curl -s -b "hadoop-jwt=${HADOOP_JWT}" "${SSB_URL}/api/v2/projects"
    The response is a JSON array. Each element describes one project, with its id, its name, and other properties.
  3. Create a job.
    curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
      -H "Content-Type: application/json" \
      -X POST "${SSB_URL}/api/v2/projects/${PROJECT_ID}/jobs" \
      -d '{
        "sql": "INSERT INTO <sink-table> SELECT * FROM <source-table>",
        "job_config": {
          "job_name": "<job-name>"
        }
      }'
    SSB saves the job and does not start it. The response contains the job_id of the new job, and its state is stopped.
  4. Start the job.
    curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
      -H "Content-Type: application/json" \
      -X POST "${SSB_URL}/api/v2/projects/${PROJECT_ID}/jobs/<job-id>/execute" \
      -d '{}'
  5. Check the state of the job.
    curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
      "${SSB_URL}/api/v2/projects/${PROJECT_ID}/jobs/<job-id>/state"
  6. Stop the job.
    curl -s -b "hadoop-jwt=${HADOOP_JWT}" \
      -H "Content-Type: application/json" \
      -X POST "${SSB_URL}/api/v2/projects/${PROJECT_ID}/jobs/<job-id>/stop" \
      -d '{"savepoint": false}'

    The savepoint property is required. To take a savepoint when the job stops, set it to true. A savepoint needs a checkpoint directory and a savepoint directory. A custom savepoint_path is not supported on Kubernetes. The optional timeout property sets how many seconds SSB waits for the job to stop. When the timeout is reached, SSB returns an error and the stop request fails. For more information, see Job settings reference.

    Only the user who started the job, or an admin or the owner of the project, can stop it. For other users, the request fails with the message It can only be stopped by that user or the project's admin/owner.

To create and start a job in one call, send the SQL and the job configuration to POST /api/v2/projects/<project-id>/sql/execute instead of steps 3 and 4.