Class: SparkConnect::Types::DataType
- Inherits:
-
Object
- Object
- SparkConnect::Types::DataType
- Defined in:
- lib/spark_connect/types.rb
Overview
Abstract base class for all Spark data types.
Direct Known Subclasses
ArrayType, BinaryType, BooleanType, ByteType, CalendarIntervalType, CharType, DateType, DayTimeIntervalType, DecimalType, DoubleType, FloatType, IntegerType, LongType, MapType, NullType, ShortType, StringType, StructType, TimestampNTZType, TimestampType, VarcharType, VariantType, YearMonthIntervalType
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #inspect ⇒ Object
-
#json ⇒ String
The JSON schema string for this type.
-
#json_value ⇒ String, Hash
The Spark JSON schema fragment for this type.
-
#simple_string ⇒ String
The Spark
simpleStringrepresentation, e.g. -
#to_proto ⇒ Spark::Connect::DataType
The protobuf representation.
- #to_s ⇒ Object
-
#type_name ⇒ String
The short type name used by Spark's JSON schema, e.g.
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
50 51 52 |
# File 'lib/spark_connect/types.rb', line 50 def ==(other) other.is_a?(self.class) && other.class == self.class end |
#hash ⇒ Object
55 56 57 |
# File 'lib/spark_connect/types.rb', line 55 def hash self.class.hash end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/spark_connect/types.rb', line 63 def inspect "#<#{self.class.name} #{simple_string}>" end |
#json ⇒ String
Returns the JSON schema string for this type.
41 42 43 |
# File 'lib/spark_connect/types.rb', line 41 def json JSON.generate(json_value) end |
#json_value ⇒ String, Hash
Returns the Spark JSON schema fragment for this type.
36 37 38 |
# File 'lib/spark_connect/types.rb', line 36 def json_value type_name end |
#simple_string ⇒ String
Returns the Spark simpleString representation, e.g. "int",
"array<string>", "struct<a:int>".
24 25 26 |
# File 'lib/spark_connect/types.rb', line 24 def simple_string type_name end |
#to_proto ⇒ Spark::Connect::DataType
Returns the protobuf representation.
46 47 48 |
# File 'lib/spark_connect/types.rb', line 46 def to_proto raise NotImplementedError, "#{self.class}#to_proto is not implemented" end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/spark_connect/types.rb', line 59 def to_s simple_string end |
#type_name ⇒ String
Returns the short type name used by Spark's JSON schema, e.g.
"integer", "long", "string".
30 31 32 33 |
# File 'lib/spark_connect/types.rb', line 30 def type_name n = self.class.name.split("::").last.sub(/Type$/, "") n.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase end |