GET /v1/tables/{id}/sampleData
from metadata.sdk import configure, client
from metadata.sdk.entities import Tables
from metadata.generated.schema.entity.data.table import TableData
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
rest = client().ometa.client
table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
# Add sample data
Tables.add_sample_data(table_id, TableData(
columns=["id", "name", "email", "created_at"],
rows=[
[1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"],
[2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"],
[3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"]
]
))
# Get sample data
table = Tables.get_sample_data(table_id)
for row in table.sampleData.rows:
print(row)
# Delete sample data
rest.delete(f"/tables/{table_id}/sampleData")
import java.util.List;
import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.type.TableData;
import org.openmetadata.sdk.network.HttpMethod;
// client is an initialized OpenMetadataClient.
String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
// Get sample data
Table sample = client.tables().getSampleData(tableId);
// Add sample data
TableData sampleData = new TableData()
.withColumns(List.of("id", "name", "email", "created_at"))
.withRows(List.of(
List.<Object>of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"),
List.<Object>of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"),
List.<Object>of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z")
));
client.tables().updateSampleData(tableId, sampleData);
// Delete sample data
client.getHttpClient().execute(
HttpMethod.DELETE,
"/v1/tables/" + tableId + "/sampleData",
null,
Void.class
);
# Get sample data
curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
# Add sample data
curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}'
# Delete sample data
curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
{
"id": "455e3d9d-dbbf-455e-b3be-7191daa825f3",
"name": "agent_performance",
"sampleData": {
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}
}
Table Sample Data
Retrieve, upload, or delete sample data rows for a table to provide data previews and examples for discovery and understanding using the Collate REST API.
GET
/
v1
/
tables
/
{id}
/
sampleData
GET /v1/tables/{id}/sampleData
from metadata.sdk import configure, client
from metadata.sdk.entities import Tables
from metadata.generated.schema.entity.data.table import TableData
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
rest = client().ometa.client
table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
# Add sample data
Tables.add_sample_data(table_id, TableData(
columns=["id", "name", "email", "created_at"],
rows=[
[1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"],
[2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"],
[3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"]
]
))
# Get sample data
table = Tables.get_sample_data(table_id)
for row in table.sampleData.rows:
print(row)
# Delete sample data
rest.delete(f"/tables/{table_id}/sampleData")
import java.util.List;
import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.type.TableData;
import org.openmetadata.sdk.network.HttpMethod;
// client is an initialized OpenMetadataClient.
String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
// Get sample data
Table sample = client.tables().getSampleData(tableId);
// Add sample data
TableData sampleData = new TableData()
.withColumns(List.of("id", "name", "email", "created_at"))
.withRows(List.of(
List.<Object>of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"),
List.<Object>of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"),
List.<Object>of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z")
));
client.tables().updateSampleData(tableId, sampleData);
// Delete sample data
client.getHttpClient().execute(
HttpMethod.DELETE,
"/v1/tables/" + tableId + "/sampleData",
null,
Void.class
);
# Get sample data
curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
# Add sample data
curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}'
# Delete sample data
curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
{
"id": "455e3d9d-dbbf-455e-b3be-7191daa825f3",
"name": "agent_performance",
"sampleData": {
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}
}
Table Sample Data
Manage sample data rows for a table. Sample data provides a preview of the table’s contents and is useful for data discovery and documentation.Get Sample Data
GET /v1/tables/{id}/sampleData
Add Sample Data
PUT /v1/tables/{id}/sampleData
Delete Sample Data
DELETE /v1/tables/{id}/sampleData
GET /v1/tables/{id}/sampleData
from metadata.sdk import configure, client
from metadata.sdk.entities import Tables
from metadata.generated.schema.entity.data.table import TableData
configure(
host="https://your-company.getcollate.io/api",
jwt_token="your-jwt-token"
)
rest = client().ometa.client
table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
# Add sample data
Tables.add_sample_data(table_id, TableData(
columns=["id", "name", "email", "created_at"],
rows=[
[1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"],
[2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"],
[3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"]
]
))
# Get sample data
table = Tables.get_sample_data(table_id)
for row in table.sampleData.rows:
print(row)
# Delete sample data
rest.delete(f"/tables/{table_id}/sampleData")
import java.util.List;
import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.type.TableData;
import org.openmetadata.sdk.network.HttpMethod;
// client is an initialized OpenMetadataClient.
String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
// Get sample data
Table sample = client.tables().getSampleData(tableId);
// Add sample data
TableData sampleData = new TableData()
.withColumns(List.of("id", "name", "email", "created_at"))
.withRows(List.of(
List.<Object>of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"),
List.<Object>of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"),
List.<Object>of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z")
));
client.tables().updateSampleData(tableId, sampleData);
// Delete sample data
client.getHttpClient().execute(
HttpMethod.DELETE,
"/v1/tables/" + tableId + "/sampleData",
null,
Void.class
);
# Get sample data
curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
# Add sample data
curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}'
# Delete sample data
curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampleData" \
-H "Authorization: Bearer {access_token}"
{
"id": "455e3d9d-dbbf-455e-b3be-7191daa825f3",
"name": "agent_performance",
"sampleData": {
"columns": ["agent_id", "performance_score"],
"rows": [
["AGT-001", 92.5],
["AGT-002", 87.3],
["AGT-003", 95.1]
]
}
}
Returns
Get returns the table. The sample data is in itssampleData field, with columns and rows arrays.
Add returns the updated table.
Delete returns the updated table, without sample data.
Response
Error Handling
| Code | Error Type | Description |
|---|---|---|
401 | UNAUTHORIZED | Invalid or missing authentication token |
403 | FORBIDDEN | User lacks permission |
404 | NOT_FOUND | Table does not exist or has no sample data |
Was this page helpful?