From 3495abbb20cb0068de5a30ed1bf5ff588842a57f Mon Sep 17 00:00:00 2001 From: Phong Tat Date: Mon, 10 Apr 2017 10:23:27 +0700 Subject: [PATCH 1/2] Remove timezone on time format as it violated with BigQuery timeformat --- lib/fluent/plugin/in_sql.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fluent/plugin/in_sql.rb b/lib/fluent/plugin/in_sql.rb index 1373c97..1c7d987 100644 --- a/lib/fluent/plugin/in_sql.rb +++ b/lib/fluent/plugin/in_sql.rb @@ -93,7 +93,7 @@ def read_attribute_for_serialization(n) if v.respond_to?(:to_msgpack) v elsif v.is_a? Time - v.strftime('%Y-%m-%d %H:%M:%S.%6N%z') + v.strftime('%Y-%m-%d %H:%M:%S.%6N') else v.to_s end From be1508d40d4ff7ea02f11463db6238d3aee37ddf Mon Sep 17 00:00:00 2001 From: Phong Tat Date: Wed, 31 Jan 2018 23:27:28 +0700 Subject: [PATCH 2/2] Output plugin: Support table > primary_key params --- lib/fluent/plugin/out_sql.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fluent/plugin/out_sql.rb b/lib/fluent/plugin/out_sql.rb index e9f8ee5..5194223 100644 --- a/lib/fluent/plugin/out_sql.rb +++ b/lib/fluent/plugin/out_sql.rb @@ -46,6 +46,7 @@ class TableElement config_param :table, :string config_param :column_mapping, :string + config_param :primary_key, :string, :default => :id config_param :num_retries, :integer, :default => 5 attr_reader :model @@ -74,8 +75,10 @@ def configure(conf) def init(base_model) # See SQLInput for more details of following code table_name = @table + primary_key = @primary_key @model = Class.new(base_model) do self.table_name = table_name + self.primary_key = primary_key self.inheritance_column = '_never_use_output_' end