Interface Schema
- All Known Implementing Classes:
ConnectSchema
,SchemaBuilder
Definition of an abstract data type. Data types can be primitive types (integer types, floating point types, boolean, strings, and bytes) or complex types (typed arrays, maps with one key schema and value schema, and structs that have a fixed set of field names each with an associated value schema). Any type can be specified as optional, allowing it to be omitted (resulting in null values when it is missing) and can specify a default value.
All schemas may have some associated metadata: a name, version, and documentation. These are all considered part of the schema itself and included when comparing schemas. Besides adding important metadata, these fields enable the specification of logical types that specify additional constraints and semantics (e.g. UNIX timestamps are just an int64, but the user needs the know about the additional semantics to interpret it properly).
Schemas can be created directly, but in most cases using SchemaBuilder
will be simpler.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
static final Schema
-
Method Summary
Modifier and TypeMethodDescriptiondoc()
Get aField
for this Schema by name.fields()
Get the list of Fields for this Schema.boolean
Get the key schema for this map schema.name()
Get a map of schema parameters.schema()
Return a concrete instance of theSchema
type()
Get the value schema for this map or array schema.version()
Get the optional version of the schema.
-
Field Details
-
INT8_SCHEMA
-
INT16_SCHEMA
-
INT32_SCHEMA
-
INT64_SCHEMA
-
FLOAT32_SCHEMA
-
FLOAT64_SCHEMA
-
BOOLEAN_SCHEMA
-
STRING_SCHEMA
-
BYTES_SCHEMA
-
OPTIONAL_INT8_SCHEMA
-
OPTIONAL_INT16_SCHEMA
-
OPTIONAL_INT32_SCHEMA
-
OPTIONAL_INT64_SCHEMA
-
OPTIONAL_FLOAT32_SCHEMA
-
OPTIONAL_FLOAT64_SCHEMA
-
OPTIONAL_BOOLEAN_SCHEMA
-
OPTIONAL_STRING_SCHEMA
-
OPTIONAL_BYTES_SCHEMA
-
-
Method Details
-
type
Schema.Type type()- Returns:
- the type of this schema
-
isOptional
boolean isOptional()- Returns:
- true if this field is optional, false otherwise
-
defaultValue
Object defaultValue()- Returns:
- the default value for this schema
-
name
String name()- Returns:
- the name of this schema
-
version
Integer version()Get the optional version of the schema. If a version is included, newer versions must be larger than older ones.- Returns:
- the version of this schema
-
doc
String doc()- Returns:
- the documentation for this schema
-
parameters
Get a map of schema parameters.- Returns:
- Map containing parameters for this schema, or null if there are no parameters
-
keySchema
Schema keySchema()Get the key schema for this map schema. Throws aDataException
if this schema is not a map.- Returns:
- the key schema
-
valueSchema
Schema valueSchema()Get the value schema for this map or array schema. Throws aDataException
if this schema is not a map or array.- Returns:
- the value schema
-
fields
Get the list of Fields for this Schema. Throws aDataException
if this schema is not aSchema.Type.STRUCT
.- Returns:
- the list of fields for this Schema
-
field
Get aField
for this Schema by name. Throws aDataException
if this schema is not aSchema.Type.STRUCT
.- Parameters:
fieldName
- the name of the field to look up- Returns:
- the Field object for the specified field, or null if there is no field with the given name
-
schema
Schema schema()Return a concrete instance of theSchema
- Returns:
- the
Schema
-