Support Questions

Find answers, ask questions, and share your expertise

Apache Atlas REST API Example (Table and Columns)

avatar
New Contributor

I am not able to add a Table with columns to an existing db and Im getting below error.

{
    "error": "Unable to deserialize json"
}

Please see below my JSON for REST API

{
	"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
	"id": {
		"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
		"id": "-12343",
		"typeName": "Table",
		"state": "ACTIVE"
	},
	"typeName": "Table",
    "tableType": "Managed",
    "temporary": false,
	"values": {
	    "db": "fbf39907-ad7d-4c40-9827-9f2c52c1a82c",
		"typeName": "Table",
		"name": "employee_details",
		"qualified_name": "employee_details",
        "description": "Employee Table",
        "owner": "Ramesh",
        "createTime": 1509391653,
		"columns": [{
			"id": {
				"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
				"state": "ACTIVE",
				"typeName": "Column",
				"id": "-12345"
			},
			"traitNames": [],
			"traits": {},
			"typeName": "Column",
			"values": {
				"comment": "Employee Id",
				"dataType": "int",
				"name": "employee_id"
			}
		}, {
			"id": {
				"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
				"state": "ACTIVE",
				"typeName": "Column",
				"id": "-12384"
			},
			"traitNames": [],
			"traits": {},
			"typeName": "Column",
			"values": {
				"comment": "Employee Name",
				"dataType": "string",
				"name": "employee_name"
			}
		}]
		
	},
	"sd": {
			"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
			"id": {
				"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
				"id": "-11893021824425523",
				"version": 0,
				"typeName": "StorageDesc",
				"state": "ACTIVE"
			},
			"typeName": "StorageDesc",
			"values": {
				"location": "hdfs://host:8000/apps/warehouse/employee",
				"outputFormat": "TextOutputFormat",
				"compressed": true,
				"inputFormat": "TextInputFormat",
				"parameters": {}
			},
			"traitNames": [],
			"traits": {}
		},
	"traitNames": [],
	"traits": {}
}
3 REPLIES 3

avatar
Expert Contributor

You seem to be using v1 APIs. What version of Atlas are you working on?

Please look at this link for V2 API usage. This has some attached JSONs and CURL calls that help with table creation.

Hope this helps.

avatar
New Contributor

Thanks @Ashutosh Mestry for your reply. Im using 1.0.0-SNAPSHOT version.

I tried your example with V2 API and it works. Do you have any example for Lineage too ? Thanks.

avatar
Expert Contributor

Attached is a small sample of lineage in action.

Use the following command to import the attached ZIP. You should see lineage for the only table present in the database.

curl -g -X POST -u admin:admin -H "Content-Type: multipart/form-data" -H "Cache-Control: no-cache" -F data=@./Stocks-2.zip "http://localhost:21000/api/atlas/admin/import"

Please extract the ZIP to see the entity definition for hive_process.

stocks-2.zip