This endpoint is in preview and may be modified or removed at any time.
To use this endpoint, add preview=true to the request query parameters.
Adds a primary key to a View that does not already have one. Primary keys are treated as guarantees provided by the creator of the dataset.
Third-party applications using this endpoint via OAuth2 must request the following operation scope: api:datasets-write.
objectstringThe name of a Branch.
objectThe primary key of the dataset. Primary keys are treated as guarantees provided by the creator of the dataset.
objectstringstringThe rid of the View.
stringThe unique resource identifier (RID) of a Folder.
stringThe branch name of the View. If not specified, defaults to master for most enrollments.
list<ViewBackingDataset>objectThe primary key of the dataset. Primary keys are treated as guarantees provided by the creator of the dataset.
1
2
3
4
5
curl -X POST \
\t-H "Content-type: application/json" \
\t-H "Authorization: Bearer $TOKEN" \
"https://$HOSTNAME/api/v2/datasets/views/ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da/addPrimaryKey?preview=true" \
-d '{"branch":"master","primaryKey":{"columns":["colA"],"resolution":{"type":"duplicate","deletionColumn":"deletionCol","resolutionStrategy":{"type":"latestWins","columns":["colB","colC"]}}}}'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"datasetRid": "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da",
"parentFolderRid": "ri.compass.main.folder.c410f510-2937-420e-8ea3-8c9bcb3c1791",
"viewName": "My Dataset",
"backingDatasets": [
{
"datasetRid": "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da",
"branch": "master"
}
],
"branch": "master",
"primaryKey": {
"columns": [
"order_id"
]
}
}| Error Name | ||
|---|---|---|
View | Error Code | CONFLICT |
| Status Code | 409 | |
| Description | A primary key already exits. | |
| Parameters | | |
View | Error Code | NOT_FOUND |
| Status Code | 404 | |
| Description | The requested View could not be found. Either the view does not exist, the branch is not valid or the client token does not have access to it. | |
| Parameters | viewDatasetRid, branch | |
View | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | No columns were provided as part of the primary key | |
| Parameters | | |
View | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | Cannot add a primary key to a View that does not have any backing datasets. | |
| Parameters | | |
Invalid | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | The type of each referenced column in the primary key must be one of the following: BYTE, SHORT, DECIMAL, INTEGER, LONG, STRING, BOOLEAN, TIMESTAMP or DATE. | |
| Parameters | primaryKeyColumns, invalidColumns | |
Not | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | Not all columns in the View's primary key are present in the dataset(s). | |
| Parameters | primaryKeyColumns, missingColumns | |
View | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | The deletion column is not present in the dataset. | |
| Parameters | deletionColumn | |
Invalid | Error Code | INVALID_ARGUMENT |
| Status Code | 400 | |
| Description | The deletion column must be a boolean. | |
| Parameters | deletionColumn, deletionColumnType | |
Add | Error Code | PERMISSION_DENIED |
| Status Code | 403 | |
| Description | Could not addPrimaryKey the View. | |
| Parameters | viewDatasetRid | |
See Errors for a general overview of errors in the platform.