Class SchemaBuilder


  • public class SchemaBuilder
    extends Object
    Convenience builder that can be used to create new Apache Arrow Schema for common types more easily than alternative methods of construction, especially for complex types.
    • Constructor Detail

      • SchemaBuilder

        public SchemaBuilder()
    • Method Detail

      • addField

        public SchemaBuilder addField​(org.apache.arrow.vector.types.pojo.Field field)
      • addField

        public SchemaBuilder addField​(String fieldName,
                                      org.apache.arrow.vector.types.pojo.ArrowType type)
        Adds a new Field with the provided details to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        type - The type of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addField

        public SchemaBuilder addField​(String fieldName,
                                      org.apache.arrow.vector.types.pojo.ArrowType type,
                                      List<org.apache.arrow.vector.types.pojo.Field> children)
        Adds a new Field with the provided details to the Schema as a top-level Field.
        Parameters:
        fieldName - The name of the field to add.
        type - The type of the field to add.
        children - The list of child fields to add to the new Field.
        Returns:
        This SchemaBuilder itself.
      • addStructField

        public SchemaBuilder addStructField​(String fieldName)
        Adds a new STRUCT Field to the Schema as a top-level Field.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addListField

        public SchemaBuilder addListField​(String fieldName,
                                          org.apache.arrow.vector.types.pojo.ArrowType type)
        Adds a new LIST Field to the Schema as a top-level Field.
        Parameters:
        fieldName - The name of the field to add.
        type - The concrete type of the values that are held within the list.
        Returns:
        This SchemaBuilder itself.
      • addChildField

        public SchemaBuilder addChildField​(String parent,
                                           String child,
                                           org.apache.arrow.vector.types.pojo.ArrowType type)
        Adds a new Field as a child of the requested top-level parent field.
        Parameters:
        parent - The name of the pre-existing top-level parent field to add a child field to.
        child - The name of the new child field.
        type - The type of the new child field to add.
        Returns:
        This SchemaBuilder itself.
      • addChildField

        public SchemaBuilder addChildField​(String parent,
                                           org.apache.arrow.vector.types.pojo.Field child)
        Adds a new Field as a child of the requested top-level parent field.
        Parameters:
        parent - The name of the pre-existing top-level parent field to add a child field to.
        child - The child field to add to the parent.
        Returns:
        This SchemaBuilder itself.
      • addStringField

        public SchemaBuilder addStringField​(String fieldName)
        Adds a new VARCHAR Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addIntField

        public SchemaBuilder addIntField​(String fieldName)
        Adds a new INT Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addTinyIntField

        public SchemaBuilder addTinyIntField​(String fieldName)
        Adds a new TINYINT Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addSmallIntField

        public SchemaBuilder addSmallIntField​(String fieldName)
        Adds a new SMALLINT Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addFloat8Field

        public SchemaBuilder addFloat8Field​(String fieldName)
        Adds a new FLOAT8 Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addFloat4Field

        public SchemaBuilder addFloat4Field​(String fieldName)
        Adds a new FLOAT4 Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addBigIntField

        public SchemaBuilder addBigIntField​(String fieldName)
        Adds a new BIGINT Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addBitField

        public SchemaBuilder addBitField​(String fieldName)
        Adds a new BIT Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addDecimalField

        public SchemaBuilder addDecimalField​(String fieldName,
                                             int precision,
                                             int scale)
        Adds a new DECIMAL Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        precision - The precision to use for the new decimal field.
        scale - The scale to use for the new decimal field.
        Returns:
        This SchemaBuilder itself.
      • addDateDayField

        public SchemaBuilder addDateDayField​(String fieldName)
        Adds a new DateDay Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addDateMilliField

        public SchemaBuilder addDateMilliField​(String fieldName)
        Adds a new DateMilli Field to the Schema as a top-level Field with no children.
        Parameters:
        fieldName - The name of the field to add.
        Returns:
        This SchemaBuilder itself.
      • addMetadata

        public SchemaBuilder addMetadata​(String key,
                                         String value)
        Adds the provided metadata to the Schema.
        Parameters:
        key - The key of the metadata to add.
        value - The value of the metadata to add.
        Returns:
        This SchemaBuilder itself.
      • getField

        public org.apache.arrow.vector.types.pojo.Field getField​(String name)
      • newBuilder

        public static SchemaBuilder newBuilder()
        Creates a new SchemaBuilder.
        Returns:
        A new SchemaBuilder.
      • build

        public org.apache.arrow.vector.types.pojo.Schema build()
        Builds an Apache Arrow Schema from the collected metadata and fields.
        Returns:
        A new Apache Arrow Schema.