CreateSemanticJob

Updated at:

Saves a reusable semantic task definition. If you use a single-file source, apply for and complete the attachment upload first. After the definition is created, call RunSemanticJob with the returned Name.

Operation description

Scenarios

Creates and saves a reusable semantic task definition. This API operation only saves the configurations of the data source, resource group, and reference files, and does not execute the task immediately.

Recommended procedure

  1. If Source.type is set to singleTableFile, call UploadSemanticFile first, use the returned Data.UploadUrl to complete the PUT upload, and then specify Data.FileId in ReferenceFileIds. Alternatively, you can provide a single accessible URI.

  2. Configure Source, ProjectId, and ResourceGroupId, and then call this operation to save the task.

  3. Call RunSemanticJob by using Data.Name in the response. After the task is completed, call DownloadSemanticResults to obtain the output.

Precautions

Name must be unique within the current tenant. The rules for the number of reference files differ between single-file sources and other sources. For details, refer to the descriptions of the ReferenceFileIds and ReferenceFileUris fields.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dataworks:CreateSemanticJob

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Name

string

Yes

The name of the semantic task, which is also the task identifier for subsequent calls to RunSemanticJob, DeleteSemanticJob, ListSemanticJobRuns, and DownloadSemanticResults. The name must be unique within the current tenant.

semantic-job-demo

ProjectId

integer

No

The ID of the DataWorks workspace. This parameter is required unless Source.type is set to singleTableFile. The Data.ProjectId in the creation result can be reused for GetSemanticJobDetail, GetSemanticJobLog, and KillSemanticJob.

100

ResourceGroupId

string

Yes

The identifier of the resource group used to run the semantic task. You do not need to pass this parameter when calling RunSemanticJob. The resource group saved during creation is used.

rg-demo

Source

object

Yes

The input data source configuration for the semantic task. The type field is required. The configuration specifies the data to analyze. This configuration is distinct from the semantic_model YAML generated by the task. The domain field is a string that identifies the business domain and focus area for the task, such as sales. Supported data sources include the following. 1) maxcompute: Specify the scope by using pinnedScopeInfo. Array elements include type and name. If type is project, name is the MaxCompute project name. If type is schema, project is the project name and name is the schema name. For a table-level scope, project is the project name, schema is optional, and name is the table name. 2) holo or starrocks: In addition to type, you must specify dataSourceName and dataSourceEnv, and include ProjectId at the top level of the request. You can use pinnedScopeInfo to restrict the scope to a schema or table. The name element represents the schema or table name. For a table-level scope, schema represents the database or schema to which the table belongs. 3) singleTableFile: ProjectId is not required. For file reference rules, refer to ReferenceFileIds and ReferenceFileUris. After the task runs successfully, call DownloadSemanticResults to retrieve result files such as the semantic_model YAML. The example demonstrates a MaxCompute project scope.

{"type":"maxcompute","domain":"sales","pinnedScopeInfo":[{"type":"project","name":"mc_project"}]}

ReferenceFileIds

array

No

The list of IDs of uploaded reference files. If Source.type is set to singleTableFile, this parameter and ReferenceFileUris are mutually exclusive, and the selected array must contain exactly one non-empty element. The ID must be obtained from Data.FileId returned by UploadSemanticFile, and the file only supports CSV or XLSX formats. For other Source.type values, you can pass multiple IDs. The service validates each ID during creation, and you can pass ReferenceFileUris at the same time.

string

No

The ID of an uploaded reference file.

semantic-job-value

ReferenceFileUris

array

No

The list of URIs of reference files accessible to the caller. If Source.type is set to singleTableFile, this parameter and ReferenceFileIds are mutually exclusive, and the selected array must contain exactly one non-empty URI. For other Source.type values, you can pass multiple URIs, and you can pass ReferenceFileIds at the same time. When using the upload path of UploadSemanticFile, pass Data.FileId after the PUT upload is completed, instead of the short-lived UploadUrl.

string

No

The URI of an accessible reference file.

semantic-job-value

Construct the call parameters based on the description of each request field.

Response elements

Element

Type

Description

Example

object

The standard response for creating a semantic task. Data contains the saved task definition. Subsequent calls use the Name, ProjectId, and reference file information in Data.

RequestId

string

The request ID. You can use this ID to locate logs and troubleshoot issues.

676271D6-53B4-57BE-89FA-72F7AE1418DF

Success

boolean

Indicates whether the request is successful.

Data

object

The saved semantic task definition. Use Data.Name to call RunSemanticJob, DeleteSemanticJob, ListSemanticJobRuns, and DownloadSemanticResults.

Id

integer

The internal unique ID of the task definition, which is used to identify the created task.

1

Name

string

The saved task name. This value is used for subsequent operations such as running, deleting, querying run records, and downloading results.

semantic-job-demo

UserId

string

The identifier of the user who created the task.

user-demo

Creator

string

The identifier of the task creator, which has the same value as UserId and identifies who created the task.

user-demo

ProjectId

integer

The ID of the DataWorks workspace to which the task belongs. This ID is used as the ProjectId for GetSemanticJobDetail, GetSemanticJobLog, and KillSemanticJob.

100

Type

string

The saved Source.type data source type, which is used to quickly identify the task input type.

maxcompute

Source

object

The saved input data source configuration, which corresponds to Source in the creation request. The data scope to be analyzed is selected based on this config during runtime.

{"type":"maxcompute","domain":"sales","pinnedScopeInfo":[{"type":"project","name":"mc_project"}]}

ReferenceFileIds

array

The list of IDs of associated uploaded files. If the source type is singleTableFile, the task reads the only file in the list at runtime.

string

The FileId returned by UploadSemanticFile. Use it after completing the PUT upload.

FID1

ReferenceFileUris

array

The list of URIs of associated external reference files. If the source type is singleTableFile, the task reads the only file in the list at runtime.

string

The URI of an accessible reference file provided by the caller.

https://example.com/reference.pdf

GmtCreate

integer

The time when the task definition was created. The value is a UNIX timestamp in milliseconds.

1700000000000

GmtModified

integer

The time when the task definition was last modified. The value is a UNIX timestamp in milliseconds.

1700000000000

ResourceGroupId

string

The identifier of the resource group to be used when running this task.

rg-demo

For the meanings of response fields and subsequent call relationships, refer to the description of each field.

Examples

Success response

JSON format

{
  "RequestId": "676271D6-53B4-57BE-89FA-72F7AE1418DF",
  "Success": false,
  "Data": {
    "Id": 1,
    "Name": "semantic-job-demo",
    "UserId": "user-demo",
    "Creator": "user-demo",
    "ProjectId": 100,
    "Type": "maxcompute",
    "Source": {
      "type": "maxcompute",
      "domain": "sales",
      "pinnedScopeInfo": [
        {
          "type": "project",
          "name": "mc_project"
        }
      ]
    },
    "ReferenceFileIds": [
      "FID1"
    ],
    "ReferenceFileUris": [
      "https://example.com/reference.pdf"
    ],
    "GmtCreate": 1700000000000,
    "GmtModified": 1700000000000,
    "ResourceGroupId": "rg-demo"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.