Export: Avro

Converts the data contract into an Avro schema. It supports specifying custom Avro properties for logical types and default values.

{/* AUTOGENERATED EXAMPLE: do not edit by hand; regenerate with the update script. */}

datacontract export avro orders.odcs.yaml --schema-name orders --output orders.avsc

Running this against the example orders contract produces:

{
  "type": "record",
  "name": "orders",
  "doc": "One row per customer order.",
  "fields": [
    {
      "name": "order_id",
      "doc": "Unique identifier of the order.",
      "type": "string"
    },
    {
      "name": "order_timestamp",
      "doc": "Timestamp when the order was placed.",
      "type": {
        "type": "int",
        "logicalType": "date"
      }
    },
    {
      "name": "customer_id",
      "doc": "Reference to the customer who placed the order.",
      "type": "string"
    },
    {
      "name": "order_total",
      "doc": "Total amount of the order in cents.",
      "type": "bytes"
    },
    {
      "name": "status",
      "doc": "Current fulfilment status of the order.",
      "type": "string"
    }
  ]
}

{/* END AUTOGENERATED EXAMPLE */}

Custom Avro properties

A config map on property level may include additional key-value pairs. At the moment, logicalType and default are supported.

schema:
  - name: orders
    properties:
      - name: my_field_1
        description: Example for AVRO with Timestamp (microsecond precision)
        logicalType: integer
        physicalType: long
        examples:
          - 1672534861000000  # 2023-01-01 01:01:01 in microseconds
        required: true
        config:
          avroLogicalType: local-timestamp-micros
          avroDefault: 1672534861000000