/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

{
  "type": "record",
  "name": "CassandraCDC",
  "namespace": "org.apache.cassandra",
  "doc": "primary_keys and partition_keys are added dynamically in RowSerializer",
  "fields": [
    {
      "name": "timestampMicros",
      "type": "long"
    },
    {
      "name": "sourceTable",
      "type": "string"
    },
    {
      "name": "sourceKeyspace",
      "type": "string"
    },
    {
      "name": "truncatedFields",
      "type": {
        "type": "array",
        "items": "string"
      }
    },
    {
      "name": "version",
      "type": ["null","string"],
      "default": null,
      "doc": "to allow serde of evolving schemas"
    },
    {
      "name": "operationType",
      "type": {
        "type": "enum",
        "name": "OperationType",
        "namespace": "org.apache.cassandra",
        "symbols": [
          "INSERT",
          "UPDATE",
          "DELETE",
          "COMPLEX_ELEMENT_DELETE",
          "DELETE_RANGE",
          "DELETE_PARTITION"
        ]
      }
    },
    {
      "name": "isPartial",
      "type": "boolean",
      "default": false
    },
    {
      "name": "updateFields",
      "doc": "used to differentiate between absent data, and data being updated to a null value (when isPartial = true)",
      "type": [
        "null",
        {
          "type": "array",
          "items": "string"
        }
      ],
      "default": null
    },
    {
      "name": "range",
      "doc": "clustering keys only - logical AND of predicates",
      "type": [
        "null",
        {
          "type": "array",
          "items": {
            "type": "record",
            "name": "RangePredicate",
            "namespace": "org.apache.cassandra",
            "fields": [
              {
                "name": "field",
                "type": "string"
              },
              {
                "name": "rangePredicateType",
                "type": {
                  "type": "enum",
                  "name": "RangePredicateType",
                  "namespace": "org.apache.cassandra",
                  "symbols": [
                    "LT",
                    "LTE",
                    "EQ",
                    "GTE",
                    "GT",
                    "IN"
                  ]
                }
              },
              {
                "name": "value",
                "doc": "table schema (same as primary payload) with only a single field populated",
                "type": "bytes"
              }
            ]
          }
        }
      ],
      "default": null
    },
    {
      "name": "ttl",
      "doc": "TTL (if any) of the associated row",
      "type": [
        "null",
        {
          "type": "record",
          "name": "TTL",
          "namespace": "org.apache.cassandra",
          "fields": [
            {
              "name": "ttl",
              "type": "int",
              "doc": "Relative time in seconds as set in the CQL query"
            },
            {
              "name": "deletedAt",
              "type": "long",
              "doc": "Future timestamp in seconds"
            }
          ]
        }
      ]
    }
  ]
}
