Class: Fluent::BigQuery::TimestampFieldSchema

Inherits:
FieldSchema
  • Object
show all
Defined in:
lib/fluent/plugin/bigquery/schema.rb

Constant Summary collapse

INTEGER_REGEXP =
/\A-?[[:digit:]]+\z/.freeze
FLOAT_REGEXP =
/\A-?[[:digit:]]+(\.[[:digit:]]+)\z/.freeze

Instance Attribute Summary

Attributes inherited from FieldSchema

#mode, #name

Instance Method Summary collapse

Methods inherited from FieldSchema

#format, #initialize, #to_h

Constructor Details

This class inherits a constructor from Fluent::BigQuery::FieldSchema

Instance Method Details

#format_one(value, is_load: false) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fluent/plugin/bigquery/schema.rb', line 147

def format_one(value, is_load: false)
  case value
  when Time
    value.strftime("%Y-%m-%d %H:%M:%S.%6L %:z")
  when String
    if value =~ INTEGER_REGEXP
      value.to_i
    elsif value =~ FLOAT_REGEXP
      value.to_f
    else
      value
    end
  else
    value
  end
end

#typeObject



143
144
145
# File 'lib/fluent/plugin/bigquery/schema.rb', line 143

def type
  :timestamp
end