Class: Arrow::Schema

Inherits:
Object
  • Object
show all
Includes:
FieldContainable
Defined in:
lib/arrow/schema.rb

Instance Method Summary collapse

Methods included from FieldContainable

#find_field

Constructor Details

#initialize(fields) ⇒ Schema #initialize(fields) ⇒ Schema

Creates a new Arrow::Schema.

Overloads:

  • #initialize(fields) ⇒ Schema

    Examples:

    Create a schema with Fields

    visible_field = Arrow::Field.new("visible", :boolean)
    Arrow::Schema.new([visible_field])

    Create a schema with field descriptions

    visible_field_description = {
      name: "visible",
      data_type: :boolean,
    }
    Arrow::Schema.new([visible_field_description])

    Create a schema with Fields and field descriptions

    fields = [
      Arrow::Field.new("visible", :boolean),
      {
        name: "count",
        type: :int32,
      },
    ]
    Arrow::Schema.new(fields)

    Parameters:

    • fields (::Array<Arrow::Field, Hash>)

      The fields of the schema. You can mix Field and field description in the fields.

      See Field.new how to specify field description.

  • #initialize(fields) ⇒ Schema

    Examples:

    Create a schema with fields

    fields = {
      "visible" => Arrow::BooleanDataType.new,
      :count => :int32,
      :tags => {
        type: :list,
        field: {
          name: "tag",
          type: :string,
        },
      },
    }
    Arrow::Schema.new(fields)

    Parameters:

    • fields (Hash{String, Symbol => Arrow::DataType, Hash})

      The pairs of field name and field data type of the schema. You can mix DataType and data description for field data type.

      See DataType.new how to specify data type description.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/arrow/schema.rb', line 78

def initialize(fields)
  case fields
  when ::Array
    fields = fields.collect do |field|
      field = Field.new(field) unless field.is_a?(Field)
      field
    end
  when Hash
    fields = fields.collect do |name, data_type|
      Field.new(name, data_type)
    end
  end
  initialize_raw(fields)
end

Instance Method Details

#to_s(show_metadata: false) ⇒ Object



96
97
98
# File 'lib/arrow/schema.rb', line 96

def to_s(show_metadata: false)
  ()
end

#to_s_rawObject



95
# File 'lib/arrow/schema.rb', line 95

alias_method :to_s_raw, :to_s