Class: SparkConnect::Types::StructField

Inherits:
Object
  • Object
show all
Defined in:
lib/spark_connect/types.rb

Overview

A single field within a StructType.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data_type, nullable: true, metadata: nil) ⇒ StructField

Returns a new instance of StructField.



325
326
327
328
329
330
# File 'lib/spark_connect/types.rb', line 325

def initialize(name, data_type, nullable: true, metadata: nil)
  @name = name.to_s
  @data_type = data_type
  @nullable = nullable
  @metadata = 
end

Instance Attribute Details

#data_typeObject (readonly)

Returns the value of attribute data_type.



323
324
325
# File 'lib/spark_connect/types.rb', line 323

def data_type
  @data_type
end

#metadataObject (readonly)

Returns the value of attribute metadata.



323
324
325
# File 'lib/spark_connect/types.rb', line 323

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



323
324
325
# File 'lib/spark_connect/types.rb', line 323

def name
  @name
end

#nullableObject (readonly)

Returns the value of attribute nullable.



323
324
325
# File 'lib/spark_connect/types.rb', line 323

def nullable
  @nullable
end

Instance Method Details

#==(other) ⇒ Object



349
350
351
352
# File 'lib/spark_connect/types.rb', line 349

def ==(other)
  other.is_a?(StructField) && other.name == name &&
    other.data_type == data_type && other.nullable == nullable
end

#json_valueObject



334
335
336
337
338
# File 'lib/spark_connect/types.rb', line 334

def json_value
  h = { "name" => name, "type" => data_type.json_value, "nullable" => nullable }
  h["metadata"] =  if 
  h
end

#simple_stringObject



332
# File 'lib/spark_connect/types.rb', line 332

def simple_string = "#{name}:#{data_type.simple_string}"

#to_protoObject



340
341
342
343
344
345
346
347
# File 'lib/spark_connect/types.rb', line 340

def to_proto
  Proto::DataType::StructField.new(
    name: name,
    data_type: data_type.to_proto,
    nullable: nullable,
    metadata:  ? JSON.generate() : nil
  )
end