Class: SparkConnect::Types::DecimalType

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataType

#hash, #inspect, #json, #to_s

Constructor Details

#initialize(precision = 10, scale = 0) ⇒ DecimalType

Returns a new instance of DecimalType.



163
164
165
166
167
# File 'lib/spark_connect/types.rb', line 163

def initialize(precision = 10, scale = 0)
  super()
  @precision = precision
  @scale = scale
end

Instance Attribute Details

#precisionInteger (readonly)

Returns total number of digits (max 38).

Returns:

  • (Integer)

    total number of digits (max 38).



159
160
161
# File 'lib/spark_connect/types.rb', line 159

def precision
  @precision
end

#scaleInteger (readonly)

Returns number of digits to the right of the decimal point.

Returns:

  • (Integer)

    number of digits to the right of the decimal point.



161
162
163
# File 'lib/spark_connect/types.rb', line 161

def scale
  @scale
end

Instance Method Details

#==(other) ⇒ Object



174
175
176
# File 'lib/spark_connect/types.rb', line 174

def ==(other)
  other.is_a?(DecimalType) && other.precision == precision && other.scale == scale
end

#json_valueObject



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

def json_value = "decimal(#{precision},#{scale})"

#simple_stringObject



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

def simple_string = "decimal(#{precision},#{scale})"

#to_protoObject



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

def to_proto = Types.wrap(decimal: Proto::DataType::Decimal.new(precision: precision, scale: scale))

#type_nameObject



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

def type_name = "decimal"