Package com.linkedin.venice.schema
Class AvroSchemaParseUtils
java.lang.Object
com.linkedin.venice.schema.AvroSchemaParseUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcoerceNumericDefaultsToFieldType(String jsonSchema) Walks the schema JSON and coerces numeric default values to the declared primitive numeric field type.static org.apache.avro.SchemaparseSchemaFromJSON(String jsonSchema, boolean extendedSchemaValidityCheckEnabled) static org.apache.avro.SchemaparseSchemaFromJSONLooseNumericValidation(String jsonSchema) Parses withSchemaParseConfiguration.LOOSE_NUMERICS, which differs from STRICT only by disablingvalidateNumericDefaultValueTypes.static org.apache.avro.SchemaparseSchemaFromJSONLooseValidation(String jsonSchema) static org.apache.avro.SchemaparseSchemaFromJSONStrictValidation(String jsonSchema)
-
Method Details
-
parseSchemaFromJSON
public static org.apache.avro.Schema parseSchemaFromJSON(String jsonSchema, boolean extendedSchemaValidityCheckEnabled) -
parseSchemaFromJSONStrictValidation
-
parseSchemaFromJSONLooseNumericValidation
Parses withSchemaParseConfiguration.LOOSE_NUMERICS, which differs from STRICT only by disablingvalidateNumericDefaultValueTypes. Numeric defaults whose JSON tier doesn't match the field's declared numeric type (e.g."default": 0for afloatfield) are accepted at parse time. All other strict checks (name validation, default-actually-matches-type, dangling-content) still apply. Note: Avro retains the originalJsonNodeas the default — it does NOT coerce the in-memory default to the declared type. UsecoerceNumericDefaultsToFieldType(String)if you need a string form that subsequently passes STRICT. -
parseSchemaFromJSONLooseValidation
-
coerceNumericDefaultsToFieldType
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 whosetypeis a textual primitive numeric name and whosedefaultis 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 beforevalidateNumericDefaultValueTypeswas enforced.
-