Class Schema.Builder

  • Enclosing class:
    Schema

    @PublicEvolving
    public static final class Schema.Builder
    extends Object
    A builder for constructing an immutable but still unresolved Schema.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • partitionKey

        public Schema.Builder partitionKey​(String... columnNames)
        Declares a partition key constraint for a set of given columns. Partition key uniquely identify a row in a table. Neither of columns in a partition can be nullable.
        Parameters:
        columnNames - columns that form a unique primary key
      • partitionKey

        public Schema.Builder partitionKey​(List<String> columnNames)
        Declares a partition key constraint for a set of given columns. Partition key uniquely identify a row in a table. Neither of columns in a partition can be nullable.
        Parameters:
        columnNames - columns that form a unique primary key
      • fromRowDataType

        public Schema.Builder fromRowDataType​(DataType type)
        Adopts all fields of the given row as physical columns of the schema.
      • physicalColumn

        public Schema.Builder physicalColumn​(String columnName,
                                             DataType type)
        Declares a physical column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
      • physicalColumn

        public Schema.Builder physicalColumn​(String columnName,
                                             DataType type,
                                             String comment)
        Declares a physical column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
        comment - description of the column
      • physicalColumn

        public Schema.Builder physicalColumn​(String columnName,
                                             DataType type,
                                             String comment,
                                             String defaultValue)
        Declares a physical column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
        comment - description of the column
        defaultValue - default value of the column
      • metadataColumn

        public Schema.Builder metadataColumn​(String columnName,
                                             DataType type)
        Declares a metadata column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
      • metadataColumn

        public Schema.Builder metadataColumn​(String columnName,
                                             DataType type,
                                             String metadataKey)
        Declares a metadata column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
        metadataKey - the key of metadata
      • metadataColumn

        public Schema.Builder metadataColumn​(String columnName,
                                             DataType type,
                                             String metadataKey,
                                             String comment)
        Declares a metadata column that is appended to this schema.
        Parameters:
        columnName - column name
        type - data type of the column
        metadataKey - the key of metadata
        comment - description of the column
      • primaryKey

        public Schema.Builder primaryKey​(String... columnNames)
        Declares a primary key constraint for a set of given columns. Primary key uniquely identify a row in a table. Neither of columns in a primary can be nullable.
        Parameters:
        columnNames - columns that form a unique primary key
      • primaryKey

        public Schema.Builder primaryKey​(List<String> columnNames)
        Declares a primary key constraint for a set of given columns. Primary key uniquely identify a row in a table. Neither of columns in a primary can be nullable.
        Parameters:
        columnNames - columns that form a unique primary key
      • build

        public Schema build()
        Returns an instance of a Schema.