Class AvroSchemaParseUtils

java.lang.Object
com.linkedin.venice.schema.AvroSchemaParseUtils

public class AvroSchemaParseUtils extends Object
  • Method Details

    • parseSchemaFromJSON

      public static org.apache.avro.Schema parseSchemaFromJSON(String jsonSchema, boolean extendedSchemaValidityCheckEnabled)
    • parseSchemaFromJSONStrictValidation

      public static org.apache.avro.Schema parseSchemaFromJSONStrictValidation(String jsonSchema)
    • parseSchemaFromJSONLooseNumericValidation

      public static org.apache.avro.Schema parseSchemaFromJSONLooseNumericValidation(String jsonSchema)
      Parses with SchemaParseConfiguration.LOOSE_NUMERICS, which differs from STRICT only by disabling validateNumericDefaultValueTypes. Numeric defaults whose JSON tier doesn't match the field's declared numeric type (e.g. "default": 0 for a float field) are accepted at parse time. All other strict checks (name validation, default-actually-matches-type, dangling-content) still apply. Note: Avro retains the original JsonNode as the default — it does NOT coerce the in-memory default to the declared type. Use coerceNumericDefaultsToFieldType(String) if you need a string form that subsequently passes STRICT.
    • parseSchemaFromJSONLooseValidation

      public static org.apache.avro.Schema parseSchemaFromJSONLooseValidation(String jsonSchema)
    • coerceNumericDefaultsToFieldType

      public static String coerceNumericDefaultsToFieldType(String jsonSchema)
      Walks the schema JSON and coerces numeric default values to the declared primitive numeric field type. For example {"name":"score","type":"float","default":0} becomes {"name":"score","type":"float","default":0.0} — making the schema strict-parse-clean without changing its semantic meaning (Avro fingerprint / parsing canonical form is unaffected since defaults are not part of the canonical form). Only acts on field specs whose type is a textual primitive numeric name and whose default is a numeric JSON value of a different tier. Does not touch unions, complex types, non-numeric defaults, or fields whose default already matches the declared type. Returns the input unchanged if no coercion was needed. Intended for use during store migration to rewrite legacy schemas registered before validateNumericDefaultValueTypes was enforced.