Calling GetSchema from REST API
This topic is posted to the CDAP wiki and will be maintained here.
This article describes the process for getting the output schema for plugins using the REST API.
The GetSchema button sends a POST
request to this endpoint:/v3/namespaces/system/apps/pipeline/services/studio/methods/v1/contexts/{namespace}/validations/stage
This endpoint expects a payload with the stage to validate and the inputSchemas to this stage. The stage object can be directly copied from the pipeline json and the inputSchemas can be left empty since it is a source. Example payload:
{
"stage":{
"name": "BigQuery",
"plugin": {
"name": "BigQueryTable",
"type": "batchsource",
"label": "BigQuery",
"artifact": {
"name": "google-cloud",
"version": "0.14.6",
"scope": "SYSTEM"
},
"properties": {
"project": "auto-detect",
"serviceFilePath": "auto-detect",
"datasetProject": "meseifan-test",
"dataset": "GCPQuickStart",
"table": "ADT_Out",
"referenceName": "test"
}
},
"outputSchema": [
{
"name": "etlSchemaBody",
"schema": ""
}
]
},
"inputSchemas":[]
}
Â
The response will be a fully populated stage object, one of the fields is "outputSchema" which will contain the schema of the input you are attempting to use. Example response:
{
"spec": {
"name": "BigQuery",
"plugin": {
"type": "batchsource",
"name": "BigQueryTable",
"properties": {
"serviceFilePath": "auto-detect",
"project": "auto-detect",
"datasetProject": "meseifan-test",
"dataset": "GCPQuickStart",
"table": "ADT_Out",
"referenceName": "test"
},
"artifact": {
"name": "google-cloud",
"version": {
"version": "0.14.6",
"major": 0,
"minor": 14,
"fix": 6
},
"scope": "SYSTEM"
}
},
"outputSchema": {
"type": "record",
"name": "output",
"fields": [
{
"name": "SRC_NTW_ID_",
"type": [ "string", "null" ]
},
{
"name": "NTW_CUST_NUM_",
"type": [ "long", "null" ]
},
{
"name": "NTW_CS_NO",
"type": [ "string", "null" ]
},
{
"name": "SRC_NTW_ID_masked",
"type": [ "string", "null" ]
},
{
"name": "NTW_CS_NO_masked",
"type": [ "string", "null" ]
}
]
},
"inputSchemas": {},
"outputPorts": {},
"portSchemas": {},
"stageLoggingEnabled": true,
"processTimingEnabled": true,
"maxPreviewRecords": 100,
"inputStages": [],
"failures": [],
}
}
Â