Class AvroSupersetSchemaUtils

java.lang.Object
com.linkedin.venice.utils.AvroSupersetSchemaUtils

public class AvroSupersetSchemaUtils extends Object
  • Method Details

    • isSupersetSchema

      public static boolean isSupersetSchema(org.apache.avro.Schema s1, org.apache.avro.Schema s2)
      Returns:
      True if is 's superset schema and false otherwise.
    • generateSupersetSchema

      public static org.apache.avro.Schema generateSupersetSchema(org.apache.avro.Schema rawExistingSchema, org.apache.avro.Schema rawNewSchema)
      Generate super-set schema of two Schemas. If we have {A,B,C} and {A,B,D} it will generate {A,B,C,D}, where C/D could be nested record change as well eg, array/map of records, or record of records. Prerequisite: The top-level schema are of type RECORD only and each field have default values. ie they are compatible schemas and the generated schema will pick the default value from new value schema.
      Parameters:
      rawExistingSchema - schema existing in the repo
      rawNewSchema - schema to be added.
      Returns:
      super-set schema of rawExistingSchema and rawNewSchema
    • getSupersetSchemaFromSchemaResponse

      public static MultiSchemaResponse.Schema getSupersetSchemaFromSchemaResponse(MultiSchemaResponse schemaResponse, int supersetSchemaId)
    • getLatestUpdateSchemaFromSchemaResponse

      public static MultiSchemaResponse.Schema getLatestUpdateSchemaFromSchemaResponse(MultiSchemaResponse schemaResponse, int supersetSchemaId)
    • validateSubsetValueSchema

      public static boolean validateSubsetValueSchema(org.apache.avro.Schema subsetValueSchema, String supersetSchemaStr)
      * Validate if the Subset Value Schema is a subset of the Superset Value Schema, here the field props are not used to check if the field is same or not.
    • validateSubsetValueSchemaForProjection

      public static boolean validateSubsetValueSchemaForProjection(org.apache.avro.Schema writerValueSchema, String inputSchemaStr)
      Relaxed variant of validateSubsetValueSchema(org.apache.avro.Schema, java.lang.String) used to decide whether the input (superset) value schema can be projected down to . On top of the strict subset rule, and recursively at every nesting level (records, array elements, map values), this tolerates the two artifacts of OpenHouse (OH) schema evolution:
      • nullable wrapping on the input side -- an input field typed [null, X] (a null-first 2-branch union, the shape OH produces so a field can default to null) matches a non-union writer field typed X; and
      • extra fields present in an input record but absent from the corresponding writer record (OH never removes columns, so the superset accumulates them at every level).
      The guardrails of the strict check still hold recursively: a writer field missing from the input, a type mismatch, reverse nullability drift ([null, X] writer vs X input), and null-last/complex unions all fail.