Creates a data contract from BigQuery, either from an exported table definition (JSON file) or directly from the BigQuery API.
{/* AUTOGENERATED EXAMPLE: do not edit by hand; regenerate with the update script. */}
Given this orders.json:
{
"kind": "bigquery#table",
"tableReference": {
"projectId": "my-gcp-project",
"datasetId": "orders",
"tableId": "orders"
},
"description": "One row per customer order.",
"schema": {
"fields": [
{ "name": "order_id", "type": "STRING", "mode": "REQUIRED", "description": "Unique identifier of the order." },
{ "name": "order_timestamp", "type": "TIMESTAMP", "mode": "REQUIRED" },
{ "name": "customer_id", "type": "STRING", "mode": "REQUIRED" },
{ "name": "order_total", "type": "NUMERIC", "mode": "REQUIRED" },
{ "name": "status", "type": "STRING", "mode": "REQUIRED" }
]
}
}
Run:
datacontract import bigquery --source orders.json
to produce the data contract:
version: 1.0.0
kind: DataContract
apiVersion: v3.1.0
id: my-data-contract
name: My Data Contract
status: draft
schema:
- name: orders
physicalType: table
description: One row per customer order.
logicalType: object
physicalName: orders
properties:
- name: order_id
physicalType: STRING
description: Unique identifier of the order.
logicalType: string
required: true
- name: order_timestamp
physicalType: TIMESTAMP
logicalType: timestamp
required: true
- name: customer_id
physicalType: STRING
logicalType: string
required: true
- name: order_total
physicalType: NUMERIC
logicalType: number
required: true
- name: status
physicalType: STRING
logicalType: string
required: true
{/* END AUTOGENERATED EXAMPLE */}