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 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.
Module Contents
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. |
|
Base class for all Schema classes. |
|
Base class for all Schema classes. |
|
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. |
Attributes
- 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', 'symbols', '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='')
Bases:
digraph inheritance9342b6adff { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AvroException" [URL="#schema_salad.avro.schema.AvroException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "SchemaException" -> "AvroException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaException" [URL="../../exceptions/index.html#schema_salad.exceptions.SchemaException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates error with the provided schema definition."]; "SchemaSaladException" -> "SchemaException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaSaladException" [URL="../../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; }schema_salad.exceptions.SchemaException
Indicates error with the provided schema definition.
- Parameters:
msg (str) –
sl (Optional[schema_salad.sourceline.SourceLine]) –
children (Optional[Sequence[SchemaSaladException]]) –
bullet_for_children (str) –
- exception schema_salad.avro.schema.SchemaParseException(msg, sl=None, children=None, bullet_for_children='')
Bases:
digraph inheritanced169f71d5f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AvroException" [URL="#schema_salad.avro.schema.AvroException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "SchemaException" -> "AvroException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaException" [URL="../../exceptions/index.html#schema_salad.exceptions.SchemaException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates error with the provided schema definition."]; "SchemaSaladException" -> "SchemaException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaParseException" [URL="#schema_salad.avro.schema.SchemaParseException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "AvroException" -> "SchemaParseException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaSaladException" [URL="../../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; }AvroException
Indicates error with the provided schema definition.
- Parameters:
msg (str) –
sl (Optional[schema_salad.sourceline.SourceLine]) –
children (Optional[Sequence[SchemaSaladException]]) –
bullet_for_children (str) –
- class schema_salad.avro.schema.Schema(atype, other_props=None)
Base class for all Schema classes.
- Parameters:
atype (str) –
other_props (Optional[PropsType]) –
- 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.
- Parameters:
- class schema_salad.avro.schema.Names(default_namespace=None)
Track name set and default namespace during parsing.
- Parameters:
default_namespace (Optional[str]) –
- 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:
digraph inheritancecfa20f43d8 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "NamedSchema" [URL="#schema_salad.avro.schema.NamedSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Named Schemas specified in NAMED_TYPES."]; "Schema" -> "NamedSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; }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:
- class schema_salad.avro.schema.PrimitiveSchema(atype, other_props=None)
Bases:
digraph inheritance309a015514 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "PrimitiveSchema" [URL="#schema_salad.avro.schema.PrimitiveSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Valid primitive types are in PRIMITIVE_TYPES."]; "Schema" -> "PrimitiveSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; }Schema
Valid primitive types are in PRIMITIVE_TYPES.
- Parameters:
atype (str) –
other_props (Optional[PropsType]) –
- class schema_salad.avro.schema.EnumSchema(name, namespace, symbols, names=None, doc=None, other_props=None)
Bases:
digraph inheritance881b940a13 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "EnumSchema" [URL="#schema_salad.avro.schema.EnumSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "NamedSchema" -> "EnumSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NamedSchema" [URL="#schema_salad.avro.schema.NamedSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Named Schemas specified in NAMED_TYPES."]; "Schema" -> "NamedSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; }NamedSchema
Named Schemas specified in NAMED_TYPES.
- Parameters:
- class schema_salad.avro.schema.ArraySchema(items, names, other_props=None)
Bases:
digraph inheritance34e8329cb5 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ArraySchema" [URL="#schema_salad.avro.schema.ArraySchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Schema" -> "ArraySchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; }Schema
Base class for all Schema classes.
- Parameters:
items (JsonDataType) –
names (Names) –
other_props (Optional[PropsType]) –
- class schema_salad.avro.schema.UnionSchema(schemas, names)
Bases:
digraph inheritance3e42bb20c3 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; "UnionSchema" [URL="#schema_salad.avro.schema.UnionSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Schema" -> "UnionSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Schema
Base class for all Schema classes.
- Parameters:
schemas (List[JsonDataType]) –
names (Names) –
- class schema_salad.avro.schema.RecordSchema(name, namespace, fields, names, schema_type='record', doc=None, other_props=None)
Bases:
digraph inheritance9f432fd7f3 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "NamedSchema" [URL="#schema_salad.avro.schema.NamedSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Named Schemas specified in NAMED_TYPES."]; "Schema" -> "NamedSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "RecordSchema" [URL="#schema_salad.avro.schema.RecordSchema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "NamedSchema" -> "RecordSchema" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Schema" [URL="#schema_salad.avro.schema.Schema",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all Schema classes."]; }NamedSchema
Named Schemas specified in NAMED_TYPES.
- Parameters:
- schema_salad.avro.schema.get_other_props(all_props, reserved_props)
Retrieve the non-reserved properties from a dictionary of properties.
- Parameters:
reserved_props (Tuple[str, Ellipsis]) – The set of reserved properties to exclude
all_props (PropsType) –
- Return type:
Optional[PropsType]
- schema_salad.avro.schema.make_avsc_object(json_data, names=None)
Build Avro Schema from data parsed out of JSON string.