Class: SparkConnect::Types::StructField
- Inherits:
-
Object
- Object
- SparkConnect::Types::StructField
- Defined in:
- lib/spark_connect/types.rb
Overview
A single field within a StructType.
Instance Attribute Summary collapse
-
#data_type ⇒ Object
readonly
Returns the value of attribute data_type.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, data_type, nullable: true, metadata: nil) ⇒ StructField
constructor
A new instance of StructField.
- #json_value ⇒ Object
- #simple_string ⇒ Object
- #to_proto ⇒ Object
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_type ⇒ Object (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 |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
323 324 325 |
# File 'lib/spark_connect/types.rb', line 323 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
323 324 325 |
# File 'lib/spark_connect/types.rb', line 323 def name @name end |
#nullable ⇒ Object (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_value ⇒ Object
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_string ⇒ Object
332 |
# File 'lib/spark_connect/types.rb', line 332 def simple_string = "#{name}:#{data_type.simple_string}" |
#to_proto ⇒ Object
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 |