@PublicEvolving public final class Schema extends Object
A schema represents the schema part of a CREATE TABLE (schema) WITH (options)
DDL
statement in SQL. It defines columns of different kind, constraints, time attributes, and
watermark strategies. It is possible to reference objects (such as functions or types) across
different catalogs.
This class is used in the API and catalogs to define an unresolved schema that will be
translated to ResolvedSchema
. Some methods of this class perform basic validation,
however, the main validation happens during the resolution. Thus, an unresolved schema can be
incomplete and might be enriched or merged with a different schema at a later stage.
Since an instance of this class is unresolved, it should not be directly persisted. The toString()
shows only a summary of the contained objects.
Modifier and Type | Class and Description |
---|---|
static class |
Schema.Builder
A builder for constructing an immutable but still unresolved
Schema . |
static class |
Schema.UnresolvedColumn
Super class for all kinds of columns in an unresolved schema.
|
static class |
Schema.UnresolvedComputedColumn
Declaration of a computed column that will be resolved to
Column.ComputedColumn during
schema resolution. |
static class |
Schema.UnresolvedConstraint
Super class for all kinds of constraints in an unresolved schema.
|
static class |
Schema.UnresolvedMetadataColumn
Declaration of a metadata column that will be resolved to
Column.MetadataColumn during
schema resolution. |
static class |
Schema.UnresolvedPhysicalColumn
Declaration of a physical column that will be resolved to
Column.PhysicalColumn during
schema resolution. |
static class |
Schema.UnresolvedPrimaryKey
Declaration of a primary key that will be resolved to
UniqueConstraint during schema
resolution. |
static class |
Schema.UnresolvedWatermarkSpec
Declaration of a watermark strategy that will be resolved to
WatermarkSpec during
schema resolution. |
Modifier and Type | Method and Description |
---|---|
static Schema |
derived()
Convenience method for stating explicitly that a schema is empty and should be fully derived
by the framework.
|
boolean |
equals(Object o) |
List<Schema.UnresolvedColumn> |
getColumns() |
Optional<Schema.UnresolvedPrimaryKey> |
getPrimaryKey() |
List<Schema.UnresolvedWatermarkSpec> |
getWatermarkSpecs() |
int |
hashCode() |
static Schema.Builder |
newBuilder()
Builder for configuring and creating instances of
Schema . |
ResolvedSchema |
resolve(SchemaResolver resolver)
Resolves the given
Schema to a validated ResolvedSchema . |
String |
toString() |
public static Schema.Builder newBuilder()
Schema
.public static Schema derived()
The semantics are equivalent to calling Schema.newBuilder().build()
.
Note that derivation depends on the context. Usually, the method that accepts a Schema
instance will mention whether schema derivation is supported or not.
public List<Schema.UnresolvedColumn> getColumns()
public List<Schema.UnresolvedWatermarkSpec> getWatermarkSpecs()
public Optional<Schema.UnresolvedPrimaryKey> getPrimaryKey()
public ResolvedSchema resolve(SchemaResolver resolver)
Schema
to a validated ResolvedSchema
.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.