Class: Fluent::BigQueryOutput::TimestampFieldSchema
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
Instance Method Details
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
|
# File 'lib/fluent/plugin/out_bigquery.rb', line 738
def format_one(value)
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
begin
Time.parse(value).strftime("%Y-%m-%d %H:%M:%S.%6L %:z")
rescue
value
end
end
else
value
end
end
|
#type ⇒ Object
734
735
736
|
# File 'lib/fluent/plugin/out_bigquery.rb', line 734
def type
:timestamp
end
|