schema_salad.avro.schema
Contains the Schema classes.
- A schema may be one of:
A record, mapping field names to field value data; An enum, containing one of a small set of symbols; An array of values, all of the same schema; A map of values, all of the same schema; A union of other schemas; A unicode string; A 32-bit signed int; A 64-bit signed long; A 32-bit floating-point float; A 64-bit floating-point double; A boolean; or Null.
Attributes
Exceptions
Indicates error with the provided schema definition. |
|
Indicates error with the provided schema definition. |
Classes
Base class for all Schema classes. |
|
Class to describe Avro name. |
|
Track name set and default namespace during parsing. |
|
Named Schemas specified in NAMED_TYPES. |
|
Valid primitive types are in PRIMITIVE_TYPES. |
|
Named Schemas specified in NAMED_TYPES. |
|
Avro array schema class. |
|
Avro map schema class. |
|
Avro named map schema class. |
|
Avro union schema class. |
|
Avro named union schema class. |
|
Named Schemas specified in NAMED_TYPES. |
Functions
|
Retrieve the non-reserved properties from a dictionary of properties. |
|
Build Avro Schema from data parsed out of JSON string. |
|
Check if a new type specification is compatible with an existing type spec. |
Module Contents
- schema_salad.avro.schema.PRIMITIVE_TYPES = ('null', 'boolean', 'string', 'int', 'long', 'float', 'double')
- schema_salad.avro.schema.NAMED_TYPES = ('enum', 'record')
- schema_salad.avro.schema.VALID_TYPES
- schema_salad.avro.schema.SCHEMA_RESERVED_PROPS = ('type', 'name', 'namespace', 'fields', 'items', 'names', 'symbols', 'values', 'doc')
- schema_salad.avro.schema.JsonDataType
- schema_salad.avro.schema.AtomicPropType
- schema_salad.avro.schema.PropType
- schema_salad.avro.schema.PropsType
- schema_salad.avro.schema.FIELD_RESERVED_PROPS = ('default', 'name', 'doc', 'order', 'type')
- schema_salad.avro.schema.VALID_FIELD_SORT_ORDERS = ('ascending', 'descending', 'ignore')
- exception schema_salad.avro.schema.AvroException(msg, sl=None, children=None, bullet_for_children='', detailed_message=None)
Bases:
schema_salad.exceptions.SchemaException
Indicates error with the provided schema definition.
- Parameters:
msg (str)
sl (Optional[schema_salad.sourceline.SourceLine])
children (Optional[collections.abc.Sequence[SchemaSaladException]])
bullet_for_children (str)
detailed_message (Optional[str])
- exception schema_salad.avro.schema.SchemaParseException(msg, sl=None, children=None, bullet_for_children='', detailed_message=None)
Bases:
AvroException
Indicates error with the provided schema definition.
- Parameters:
msg (str)
sl (Optional[schema_salad.sourceline.SourceLine])
children (Optional[collections.abc.Sequence[SchemaSaladException]])
bullet_for_children (str)
detailed_message (Optional[str])
- class schema_salad.avro.schema.Schema(atype, other_props=None)
Base class for all Schema classes.
- Parameters:
atype (str)
other_props (Optional[PropsType])
- type
- property props: PropsType
- Return type:
PropsType
- class schema_salad.avro.schema.Name(name_attr=None, space_attr=None, default_space=None)
Class to describe Avro name.
- class schema_salad.avro.schema.Names(default_namespace=None)
Track name set and default namespace during parsing.
- Parameters:
default_namespace (Optional[str])
- names: dict[str, NamedSchema]
- default_namespace
- has_name(name_attr, space_attr)
- get_name(name_attr, space_attr)
Fetch the stored schema for the given namespace.
- Parameters:
- Return type:
Optional[NamedSchema]
- add_name(name_attr, space_attr, new_schema)
Add a new schema object to the name set.
- Parameters:
name_attr (str) – name value read in schema
space_attr (Optional[str]) – namespace value read in schema.
new_schema (NamedSchema)
- Returns:
the Name that was just added.
- Return type:
- class schema_salad.avro.schema.NamedSchema(atype, name, namespace=None, names=None, other_props=None)
Bases:
Schema
Named Schemas specified in NAMED_TYPES.
- Parameters:
- class schema_salad.avro.schema.Field(atype, name, has_default, default=None, order=None, names=None, doc=None, other_props=None)
- Parameters:
- type
- name
- class schema_salad.avro.schema.PrimitiveSchema(atype, other_props=None)
Bases:
Schema
Valid primitive types are in PRIMITIVE_TYPES.
- Parameters:
atype (str)
other_props (Optional[PropsType])
- fullname
- class schema_salad.avro.schema.EnumSchema(name, namespace, symbols, names=None, doc=None, other_props=None)
Bases:
NamedSchema
Named Schemas specified in NAMED_TYPES.
- Parameters:
- class schema_salad.avro.schema.ArraySchema(items, names, other_props=None)
Bases:
Schema
Avro array schema class.
- Parameters:
items (JsonDataType)
names (Names)
other_props (Optional[PropsType])
- class schema_salad.avro.schema.MapSchema(values, names, other_props=None)
Bases:
Schema
Avro map schema class.
- Parameters:
values (JsonDataType)
names (Names)
other_props (Optional[PropsType])
- class schema_salad.avro.schema.NamedMapSchema(values, names, name, namespace=None, doc=None, other_props=None)
Bases:
NamedSchema
Avro named map schema class.
- Parameters:
- class schema_salad.avro.schema.NamedUnionSchema(schemas, names, name, namespace=None, doc=None)
Bases:
NamedSchema
Avro named union schema class.
- Parameters:
- class schema_salad.avro.schema.RecordSchema(name, namespace, fields, names, schema_type='record', doc=None, other_props=None)
Bases:
NamedSchema
Named Schemas specified in NAMED_TYPES.
- Parameters:
- static make_field_objects(field_data, names)
We’re going to need to make message parameters too.
- schema_salad.avro.schema.get_other_props(all_props, reserved_props)
Retrieve the non-reserved properties from a dictionary of properties.
- schema_salad.avro.schema.make_avsc_object(json_data, names=None)
Build Avro Schema from data parsed out of JSON string.