Class AvroCelTypeProvider

java.lang.Object
io.confluent.kafka.schemaregistry.rules.cel.avro.AvroCelTypeProvider
All Implemented Interfaces:
dev.cel.common.types.CelTypeProvider

public final class AvroCelTypeProvider extends Object implements dev.cel.common.types.CelTypeProvider
A CelTypeProvider that surfaces Avro Schema record types as CEL StructTypes. Used by the compiler so this.field type-checks against the actual Avro field types rather than against dyn.

The runtime continues to receive Avro values as Map<String, Object> (via CelUtils.toCelValue); Google cel-java's runtime treats Maps as natively selectable, so no CelValueProvider counterpart is needed.

Walks the supplied schema graph, registering each reachable record schema as a StructType. Field types map to CEL types per the standard Avro→CEL mapping; nested records become StructTypeReferences (resolved at type-check time against this same provider).

Schemas this provider can't cleanly represent (e.g., multi-branch unions mixing record + scalar) yield dyn for the field; the surrounding record type is still registered. If the surrounding record itself is unrepresentable, callers fall back to declaring this as MapType(STRING, DYN).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface dev.cel.common.types.CelTypeProvider

    dev.cel.common.types.CelTypeProvider.CombinedCelTypeProvider
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<dev.cel.common.types.CelType>
    findType(String typeName)
     
    forSchema(org.apache.avro.Schema root)
    Build a provider that registers all record schemas reachable from root.
    boolean
    Returns true iff there's at least one record we can describe.
    com.google.common.collect.ImmutableCollection<dev.cel.common.types.CelType>
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • forSchema

      public static AvroCelTypeProvider forSchema(org.apache.avro.Schema root)
      Build a provider that registers all record schemas reachable from root.
    • hasAnyType

      public boolean hasAnyType()
      Returns true iff there's at least one record we can describe.
    • types

      public com.google.common.collect.ImmutableCollection<dev.cel.common.types.CelType> types()
      Specified by:
      types in interface dev.cel.common.types.CelTypeProvider
    • findType

      public Optional<dev.cel.common.types.CelType> findType(String typeName)
      Specified by:
      findType in interface dev.cel.common.types.CelTypeProvider