Search documentation
karat

+

K

User Documentation ↗
Version 2.0

Put Dataset Schema

PUT/api/v2/datasets/{datasetRid}/putSchema
Warning

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 schema on an existing dataset using a PUT request.

Third-party applications using this endpoint via OAuth2 must request the following operation scope: api:datasets-write.

Path parameters

datasetRid
string

The Resource Identifier (RID) of a Dataset.

Query parameters

preview
boolean
optional

Enables the use of preview functionality.

Request body

PutDatasetSchemaRequest
object
Hide child attributes

Hide child attributes

branchName
string
optional

The name of a Branch.

endTransactionRid
string
optional

The Resource Identifier (RID) of the end Transaction.

schema
object

The schema that will be added.

Show child attributes

Show child attributes

Response body

GetDatasetSchemaResponse
object
Hide child attributes

Hide child attributes

branchName
string

The name of a Branch.

endTransactionRid
string

The Resource Identifier (RID) of a Transaction.

schema
object

The schema for a Foundry dataset. Files uploaded to this dataset must match this schema.

Show child attributes

Show child attributes

versionId
string

The version identifier of a dataset schema.

Examples

Request

Copied!
1 2 3 4 5 curl -X PUT \ -H "Content-type: application/json" \ -H "Authorization: Bearer $TOKEN" \ "https://$HOSTNAME/api/v2/datasets/ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da/putSchema?preview=true" \ -d '{"endTransactionRid":"ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4","schema":{"fieldSchemaList":[{"name":"id","type":"long","nullable":false,"customMetadata":{"description":"Primary key"}},{"name":"event_time","type":"timestamp","nullable":false},{"name":"price","type":"decimal","precision":10,"scale":2,"nullable":true},{"name":"tags","type":"array","nullable":true,"arraySubtype":{"type":"string","nullable":false}},{"name":"metrics","type":"struct","nullable":true,"subSchemas":[{"name":"temperature","type":"double","nullable":true},{"name":"humidity","type":"double","nullable":true}]}]},"branchName":"master"}'

Response

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 { "endTransactionRid": "ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4", "schema": { "fieldSchemaList": [ { "name": "id", "type": "long", "nullable": false, "customMetadata": { "description": "Primary key" } }, { "name": "event_time", "type": "timestamp", "nullable": false }, { "name": "price", "type": "decimal", "precision": 10, "scale": 2, "nullable": true }, { "name": "tags", "type": "array", "nullable": true, "arraySubtype": { "type": "string", "nullable": false } }, { "name": "metrics", "type": "struct", "nullable": true, "subSchemas": [ { "name": "temperature", "type": "double", "nullable": true }, { "name": "humidity", "type": "double", "nullable": true } ] } ] }, "versionId": "0000000d-2acf-537c-a228-3a9fe3cdc523", "branchName": "master" }

Error responses

Error Name
BranchNotFoundError CodeNOT_FOUND
Status Code404
DescriptionThe requested branch could not be found, or the client token does not have access to it.
ParametersdatasetRid, branchName
DatasetNotFoundError CodeNOT_FOUND
Status Code404
DescriptionThe requested dataset could not be found, or the client token does not have access to it.
ParametersdatasetRid
InvalidSchemaError CodeINVALID_ARGUMENT
Status Code400
DescriptionThe schema failed validations
ParameterserrorType, message
DatasetViewNotFoundError CodeNOT_FOUND
Status Code404
DescriptionThe requested dataset view could not be found. A dataset view represents the effective file contents of a dataset for a branch at a point in time, calculated from transactions (SNAPSHOT, APPEND, UPDATE, DELETE). The view may not exist if the dataset has no transactions, contains no files, the branch is not valid, or the client token does not have access to it.
ParametersdatasetRid, branch
PutDatasetSchemaPermissionDeniedError CodePERMISSION_DENIED
Status Code403
DescriptionCould not putSchema the Dataset.
ParametersdatasetRid