java.lang.Object
io.confluent.kafka.schemaregistry.type.logical.Schema

public abstract class Schema extends Object
  • Field Details

    • NO_PARAM

      public static final int NO_PARAM
      See Also:
    • MAX_LENGTH

      public static final int MAX_LENGTH
      See Also:
    • DEFAULT_LENGTH

      public static final int DEFAULT_LENGTH
      See Also:
    • DEFAULT_DECIMAL_PRECISION

      public static final int DEFAULT_DECIMAL_PRECISION
      See Also:
    • DEFAULT_DECIMAL_SCALE

      public static final int DEFAULT_DECIMAL_SCALE
      See Also:
    • DEFAULT_TIME_PRECISION

      public static final int DEFAULT_TIME_PRECISION
      See Also:
    • DEFAULT_TIMESTAMP_PRECISION

      public static final int DEFAULT_TIMESTAMP_PRECISION
      See Also:
    • PROTOBUF_FIELD_NUMBER

      public static final String PROTOBUF_FIELD_NUMBER
      Reserved params key carrying a field's Protobuf field number, populated by the Protobuf reader from FieldDescriptor.getNumber(). Read via Schema.Field.getFieldNumber(). Part of the protobuf. format-native reserved namespace: it mirrors a Protobuf-native slot (the field number) that the LT type system has no home for, so it is emitted through that native slot and stripped from any generic param container. See isFormatNativeParam(String).
      See Also:
    • PROTOBUF_ENUM_NUMBER

      public static final String PROTOBUF_ENUM_NUMBER
      Reserved params key carrying an enum value's Protobuf number, populated by the Protobuf reader from EnumValueDescriptor.getNumber(). Read via Schema.EnumValue.getEnumNumber(). Format-native on the same terms as PROTOBUF_FIELD_NUMBER. Unlike a field number it may be negative and may repeat (Protobuf's allow_alias).
      See Also:
    • AVRO_ALIASES

      public static final String AVRO_ALIASES
      Reserved params key carrying a field's Avro aliases (its previous names) as a comma-delimited string, populated by the Avro reader from Schema.Field.aliases(). Read via Schema.Field.getAliases(). Avro field names cannot contain commas, so the delimiter is unambiguous. Part of the avro. format-native reserved namespace: it mirrors an Avro-native slot (aliases) that the LT type system has no home for, so it is emitted through that native slot and stripped from any generic param container. See isFormatNativeParam(String).
      See Also:
  • Method Details

    • isFormatNativeParam

      public static boolean isFormatNativeParam(String key)
      True if key belongs to a format-native reserved param namespace (avro. or protobuf.). Such params are authoritative only through their owning format's native slot (Avro aliases, Protobuf field number); in every generic param container (confluent:params, Protobuf field_meta.params) they are stripped on write and ignored on read. They enter and leave the LT param map only via the owning format's native slot or via a DDL WITH clause. This is distinct from the logical. / connect. / flink. namespaces, whose values are absorbed into the LT type/structure and never persist as LT params.
    • stripFormatNativeParams

      public static Map<String,Object> stripFormatNativeParams(Map<String,Object> params)
      Return params with every format-native key removed, or the same map unchanged when it contains none. Used by the format writers/readers to keep their generic param containers (confluent:params, Protobuf field_meta.params) free of keys that are authoritative only through a native slot.
    • getType

      public Schema.Type getType()
    • isNullable

      public boolean isNullable()
    • setNullable

      public Schema setNullable(boolean nullable)
    • getDoc

      public String getDoc()
    • setDoc

      public Schema setDoc(String doc)
    • getTags

      public List<String> getTags()
    • setTags

      public Schema setTags(List<String> tags)
    • getParams

      public Map<String,Object> getParams()
    • getAliases

      public List<String> getAliases()
      This named type's Avro aliases (its previous names), or an empty list when AVRO_ALIASES is unset. Values stored by the Avro reader are always fullnames, since Avro resolves relative aliases at parse time; the param is also settable through a DDL WITH clause or setParams(java.util.Map<java.lang.String, java.lang.Object>), and those values are returned as written. Avro fixed is out of scope: it converts to an unnamed type with no home for them.
    • setParams

      public Schema setParams(Map<String,Object> params)
    • getRules

      public List<Rule> getRules()
      Validation rules attached to this schema. For struct types this carries table-level CHECK constraints (constraints that may reference any field). Empty for non-struct schemas in the typical case.
    • setRules

      public Schema setRules(List<Rule> rules)
    • getFields

      public List<Schema.Field> getFields()
    • getField

      public Schema.Field getField(String name)
    • getEnumValues

      public List<Schema.EnumValue> getEnumValues()
    • getBranches

      public List<Schema.UnionBranch> getBranches()
    • getElementType

      public Schema getElementType()
    • getKeyType

      public Schema getKeyType()
    • getValueType

      public Schema getValueType()
    • getPrecision

      public int getPrecision()
    • getScale

      public int getScale()
    • getLength

      public int getLength()
    • getQualifiedName

      public String getQualifiedName()
    • toDdl

      public abstract String toDdl()
    • withNullableSuffix

      protected String withNullableSuffix(String ddl)
    • create

      public static Schema create(Schema.Type type)
    • createDecimal

      public static Schema createDecimal(int precision, int scale)
    • createString

      public static Schema createString()
      Creates an unbounded string type (alias for VARCHAR(MAX_LENGTH)).
    • createVarchar

      public static Schema createVarchar(int length)
    • createChar

      public static Schema createChar(int length)
    • createBytes

      public static Schema createBytes()
      Creates an unbounded bytes type (alias for VARBINARY(MAX_LENGTH)).
    • createBinary

      public static Schema createBinary(int length)
    • createVarbinary

      public static Schema createVarbinary(int length)
    • createTime

      public static Schema createTime(int precision)
    • createTimestamp

      public static Schema createTimestamp(int precision)
    • createTimestampLtz

      public static Schema createTimestampLtz(int precision)
    • createStruct

      public static Schema createStruct(List<Schema.Field> fields)
    • createEnum

      public static Schema createEnum(List<Schema.EnumValue> values)
    • createUnion

      public static Schema createUnion(List<Schema.UnionBranch> branches)
    • createArray

      public static Schema createArray(Schema elementType)
    • createMultiset

      public static Schema createMultiset(Schema elementType)
    • createMap

      public static Schema createMap(Schema keyType, Schema valueType)
    • createNamedTypeRef

      public static Schema createNamedTypeRef(String qualifiedName)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isCelReservedName

      public static boolean isCelReservedName(String name)
      True if name matches a CEL reserved word (case-insensitive). The translator uses this to switch between dot-syntax and index-syntax column-ref emit so reserved-name fields still produce valid CEL.
    • quoteIdentifierIfNeeded

      public static String quoteIdentifierIfNeeded(String name)
      Quote name as a DDL identifier if it would otherwise fail to tokenize as one — i.e. it's empty, contains non-identifier characters, matches a SQL keyword that the grammar doesn't accept as an identifier, or matches a CEL reserved word (so CHECK references emit cleanly). Quoted form: backtick-wrap and double internal backticks.

      Used by both toDdl() and the LT-to-DDL converter so identifier emission is consistent across paths.