Skip to main content

can_promote

Function can_promote 

Source
fn can_promote(writer: &SchemaPiece, reader: &SchemaPiece) -> bool
Expand description

Returns true if a value written with primitive schema writer can be read as primitive reader under Avro’s numeric promotion rules: int → long/float/double, long → float/double, and float → double.

These are exactly the promotions performed during schema resolution in reader.rs (ResolveIntLong, ResolveIntDouble, …). The two must be kept in sync: only return true here for a pair that resolution can actually decode, otherwise a union variant would match but fail to resolve.