Class AvroResultWriter

java.lang.Object
io.confluent.kafka.schemaregistry.rules.cel.avro.AvroResultWriter

public final class AvroResultWriter extends Object
Converts a CEL evaluation result (typically a Map literal or scalar) back into the Avro representation matching a target Schema. Constructs GenericRecords field-by-field via GenericRecordBuilder so we never roundtrip through JSON — that roundtrip lossily encodes bytes as base64, requires {"branchName":...} tagging for unions, and can't narrow CEL's widened int64 back to an int field.

Used only by the Avro path of CelExecutor#transform; JSON Schema and Protobuf targets keep their existing conversion paths.

  • Method Details

    • convert

      public static Object convert(Object celValue, org.apache.avro.Schema schema)
      Convert celValue into the Avro shape required by schema. Recursively walks records, unions, arrays, and maps. For logical types, delegates to Avro's own Conversion infrastructure by passing the value through unchanged — the caller's GenericRecordBuilder (or the downstream serializer's GenericData) handles InstantLong, BigDecimal ↔ bytes+scale, etc.