Class AvroCelTypeProvider
- All Implemented Interfaces:
dev.cel.common.types.CelTypeProvider
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 TypeMethodDescriptionOptional<dev.cel.common.types.CelType>static AvroCelTypeProviderforSchema(org.apache.avro.Schema root) Build a provider that registers all record schemas reachable fromroot.booleanReturns true iff there's at least one record we can describe.com.google.common.collect.ImmutableCollection<dev.cel.common.types.CelType>types()
-
Method Details
-
forSchema
Build a provider that registers all record schemas reachable fromroot. -
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:
typesin interfacedev.cel.common.types.CelTypeProvider
-
findType
- Specified by:
findTypein interfacedev.cel.common.types.CelTypeProvider
-