Skip to content

Support LogicalTypes in AVRO #415

@jeroenvandisseldorp

Description

@jeroenvandisseldorp

AVRO supports logical types, but KSML can not handle these yet.

Example:

{
  "type": "record",
  "name": "CreditCardTransaction",
  "namespace": "com.example.payment",
  "doc": "Represents a credit card transaction",
  "fields": [
    {
      "name": "transaction_id",
      "type": "string",
      "doc": "Unique identifier for the transaction"
    },
    {
      "name": "card_number_last4",
      "type": "string",
      "doc": "Last 4 digits of the credit card number"
    },
    {
      "name": "merchant_id",
      "type": "string",
      "doc": "Identifier for the merchant"
    },
    {
      "name": "merchant_name",
      "type": "string",
      "doc": "Name of the merchant"
    },
    {
      "name": "amount",
      "type": {
        "type": "bytes",
        "logicalType": "decimal",
        "precision": 10,
        "scale": 2
      },
      "doc": "Transaction amount in the specified currency"
    },
    {
      "name": "currency",
      "type": "string",
      "default": "USD",
      "doc": "ISO 4217 currency code"
    },
    {
      "name": "transaction_timestamp",
      "type": {
        "type": "long",
        "logicalType": "timestamp-millis"
      },
      "doc": "Timestamp of when the transaction occurred"
    },
    {
      "name": "transaction_type",
      "type": {
        "type": "enum",
        "name": "TransactionType",
        "symbols": ["PURCHASE", "REFUND", "AUTHORIZATION", "VOID"]
      },
      "doc": "Type of transaction"
    },
    {
      "name": "status",
      "type": {
        "type": "enum",
        "name": "TransactionStatus",
        "symbols": ["PENDING", "APPROVED", "DECLINED", "FAILED"]
      },
      "doc": "Current status of the transaction"
    },
    {
      "name": "card_type",
      "type": ["null", "string"],
      "default": null,
      "doc": "Type of credit card (VISA, MASTERCARD, AMEX, etc.)"
    },
    {
      "name": "billing_zip_code",
      "type": ["null", "string"],
      "default": null,
      "doc": "Billing ZIP/postal code"
    },
    {
      "name": "authorization_code",
      "type": ["null", "string"],
      "default": null,
      "doc": "Authorization code from the payment processor"
    },
    {
      "name": "metadata",
      "type": ["null", {
        "type": "map",
        "values": "string"
      }],
      "default": null,
      "doc": "Additional metadata about the transaction"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions