fluent-plugin-sql 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +1 -1
- data/.github/workflows/linux-ruby-head.yml +3 -3
- data/.github/workflows/linux.yml +14 -5
- data/ChangeLog +10 -0
- data/VERSION +1 -1
- data/fluent-plugin-sql.gemspec +2 -1
- data/lib/fluent/plugin/out_sql.rb +10 -7
- data/test/fixtures/schema.rb +5 -1
- data/test/plugin/test_out_sql.rb +39 -4
- metadata +32 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 197db6803c87ca64448c432656a89d879f8e465258928e697d487ad16fd462b6
|
|
4
|
+
data.tar.gz: 89a4f1866a939aaec3122ba8259f4d9a74d851175743c117984ab2e29cc757bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b22a4fefd2608b511a17247e92ee07ef475a570c9f1b17e713156ced301b69d51ff994d2e2ed39832134241227fa24fd381fe792b97ccf38cf212ccc01d9f9b4
|
|
7
|
+
data.tar.gz: 00eae6b85e603667715d5ddd72f788dd1c8614cd8b0cb5c31d7d515cdba8f2aec3d84b39f12c8c6a6e65951c42c6d13189be54129a8d1022d0b333165c87ee8d
|
data/.github/dependabot.yml
CHANGED
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
13
|
ruby: [ 'head' ]
|
|
14
|
-
postgres: [ '
|
|
14
|
+
postgres: [ '18', '17', '16', '15', '14' ]
|
|
15
15
|
os:
|
|
16
16
|
- ubuntu-latest
|
|
17
17
|
services:
|
|
@@ -30,8 +30,8 @@ jobs:
|
|
|
30
30
|
--health-retries 5
|
|
31
31
|
name: Ruby ${{ matrix.ruby }} with PostgreSQL ${{ matrix.postgres }} unit testing on ${{ matrix.os }}
|
|
32
32
|
steps:
|
|
33
|
-
- uses: actions/checkout@
|
|
34
|
-
- uses: ruby/setup-ruby@v1
|
|
33
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
34
|
+
- uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
|
|
35
35
|
with:
|
|
36
36
|
ruby-version: ${{ matrix.ruby }}
|
|
37
37
|
bundler-cache: true
|
data/.github/workflows/linux.yml
CHANGED
|
@@ -4,15 +4,24 @@ on:
|
|
|
4
4
|
branches: [master]
|
|
5
5
|
pull_request:
|
|
6
6
|
branches: [master]
|
|
7
|
-
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '0 0 1 * *'
|
|
8
9
|
jobs:
|
|
10
|
+
ruby-versions:
|
|
11
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
12
|
+
with:
|
|
13
|
+
engine: cruby
|
|
14
|
+
min_version: 2.7
|
|
9
15
|
build:
|
|
16
|
+
needs: ruby-versions
|
|
10
17
|
runs-on: ${{ matrix.os }}
|
|
11
18
|
strategy:
|
|
12
19
|
fail-fast: false
|
|
13
20
|
matrix:
|
|
14
|
-
ruby:
|
|
15
|
-
|
|
21
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
22
|
+
exclude:
|
|
23
|
+
- ruby: head
|
|
24
|
+
postgres: [ '18', '17', '16', '15', '14' ]
|
|
16
25
|
os:
|
|
17
26
|
- ubuntu-latest
|
|
18
27
|
services:
|
|
@@ -31,8 +40,8 @@ jobs:
|
|
|
31
40
|
--health-retries 5
|
|
32
41
|
name: Ruby ${{ matrix.ruby }} with PostgreSQL ${{ matrix.postgres }} unit testing on ${{ matrix.os }}
|
|
33
42
|
steps:
|
|
34
|
-
- uses: actions/checkout@
|
|
35
|
-
- uses: ruby/setup-ruby@v1
|
|
43
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
44
|
+
- uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
|
|
36
45
|
with:
|
|
37
46
|
ruby-version: ${{ matrix.ruby }}
|
|
38
47
|
bundler-cache: true
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
Release 2.3.3 - 2026/05/18
|
|
2
|
+
|
|
3
|
+
* out_sql: fix unmapped columns being explicitly set to NULL on INSERT (#169)
|
|
4
|
+
|
|
5
|
+
Release 2.3.2 - 2026/01/13
|
|
6
|
+
|
|
7
|
+
* out_sql: Use isolated connection configurations in the output plugin (#152)
|
|
8
|
+
* gem: Add ostruct as dependency for Ruby 4.0 (#159)
|
|
9
|
+
* gem: Relax required activesupport version to accept latest one (#161, #148)
|
|
10
|
+
|
|
1
11
|
Release 2.3.1 - 2024/02/29
|
|
2
12
|
|
|
3
13
|
* in_sql: Fix incompatibility against Ruby 3.2
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.3.
|
|
1
|
+
2.3.3
|
data/fluent-plugin-sql.gemspec
CHANGED
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
gem.license = "Apache-2.0"
|
|
18
18
|
|
|
19
19
|
gem.add_dependency "fluentd", [">= 1.7.0", "< 2"]
|
|
20
|
-
gem.add_dependency
|
|
20
|
+
gem.add_dependency "ostruct", '~> 0.6'
|
|
21
|
+
gem.add_dependency 'activerecord', [">= 6.1", "< 8.2"]
|
|
21
22
|
gem.add_dependency 'activerecord-import', "~> 1.0"
|
|
22
23
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
|
23
24
|
gem.add_development_dependency "test-unit", "> 3.1.0"
|
|
@@ -90,23 +90,26 @@ module Fluent::Plugin
|
|
|
90
90
|
|
|
91
91
|
def import(chunk, output)
|
|
92
92
|
tag = chunk.metadata.tag
|
|
93
|
+
columns = []
|
|
93
94
|
records = []
|
|
94
95
|
chunk.msgpack_each { |time, data|
|
|
95
96
|
begin
|
|
96
97
|
data = output.inject_values_to_record(tag, time, data)
|
|
97
|
-
|
|
98
|
+
new_record = @format_proc.call(data)
|
|
99
|
+
columns |= new_record.keys
|
|
100
|
+
records << @model.new(new_record)
|
|
98
101
|
rescue => e
|
|
99
102
|
args = {error: e, table: @table, record: Yajl.dump(data)}
|
|
100
103
|
@log.warn "Failed to create the model. Ignore a record:", args
|
|
101
104
|
end
|
|
102
105
|
}
|
|
103
106
|
begin
|
|
104
|
-
@model.import(records)
|
|
107
|
+
@model.import(columns, records)
|
|
105
108
|
rescue ActiveRecord::StatementInvalid, ActiveRecord::Import::MissingColumnError => e
|
|
106
109
|
if @enable_fallback
|
|
107
110
|
# ignore other exceptions to use Fluentd retry mechanizm
|
|
108
111
|
@log.warn "Got deterministic error. Fallback to one-by-one import", error: e
|
|
109
|
-
one_by_one_import(records)
|
|
112
|
+
one_by_one_import(columns, records)
|
|
110
113
|
else
|
|
111
114
|
@log.warn "Got deterministic error. Fallback is disabled", error: e
|
|
112
115
|
raise e
|
|
@@ -114,11 +117,11 @@ module Fluent::Plugin
|
|
|
114
117
|
end
|
|
115
118
|
end
|
|
116
119
|
|
|
117
|
-
def one_by_one_import(records)
|
|
120
|
+
def one_by_one_import(columns, records)
|
|
118
121
|
records.each { |record|
|
|
119
122
|
retries = 0
|
|
120
123
|
begin
|
|
121
|
-
@model.import([record])
|
|
124
|
+
@model.import(columns, [record])
|
|
122
125
|
rescue ActiveRecord::StatementInvalid, ActiveRecord::Import::MissingColumnError => e
|
|
123
126
|
@log.error "Got deterministic error again. Dump a record", error: e, record: record
|
|
124
127
|
rescue => e
|
|
@@ -206,7 +209,7 @@ module Fluent::Plugin
|
|
|
206
209
|
end
|
|
207
210
|
|
|
208
211
|
SQLOutput.const_set("BaseModel_#{rand(1 << 31)}", @base_model)
|
|
209
|
-
|
|
212
|
+
@base_model.establish_connection(config)
|
|
210
213
|
|
|
211
214
|
# ignore tables if TableElement#init failed
|
|
212
215
|
@tables.reject! do |te|
|
|
@@ -224,7 +227,7 @@ module Fluent::Plugin
|
|
|
224
227
|
end
|
|
225
228
|
|
|
226
229
|
def write(chunk)
|
|
227
|
-
|
|
230
|
+
@base_model.connection_pool.with_connection do
|
|
228
231
|
|
|
229
232
|
@tables.each { |table|
|
|
230
233
|
tag = format_tag(chunk.metadata.tag)
|
data/test/fixtures/schema.rb
CHANGED
|
@@ -27,5 +27,9 @@ ActiveRecord::Schema.define(version: 20160225030107) do
|
|
|
27
27
|
t.datetime "updated_at", null: false
|
|
28
28
|
t.string "custom_time"
|
|
29
29
|
end
|
|
30
|
-
end
|
|
31
30
|
|
|
31
|
+
create_table "messages_unmapped", force: :cascade do |t|
|
|
32
|
+
t.string "message"
|
|
33
|
+
t.string "status", default: 'default_status'
|
|
34
|
+
end
|
|
35
|
+
end
|
data/test/plugin/test_out_sql.rb
CHANGED
|
@@ -80,6 +80,41 @@ class SqlOutputTest < Test::Unit::TestCase
|
|
|
80
80
|
assert_equal(["message1", "message2"], messages)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
def test_unmapped_column_uses_db_default
|
|
84
|
+
config = %[
|
|
85
|
+
host localhost
|
|
86
|
+
port 5432
|
|
87
|
+
adapter postgresql
|
|
88
|
+
|
|
89
|
+
database fluentd_test
|
|
90
|
+
username fluentd
|
|
91
|
+
password fluentd
|
|
92
|
+
|
|
93
|
+
schema_search_path public
|
|
94
|
+
|
|
95
|
+
remove_tag_prefix db
|
|
96
|
+
|
|
97
|
+
<table>
|
|
98
|
+
table messages_unmapped
|
|
99
|
+
column_mapping message:message
|
|
100
|
+
</table>
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
d = create_driver(config)
|
|
104
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
|
105
|
+
|
|
106
|
+
d.run(default_tag: 'test') do
|
|
107
|
+
d.feed(time, {'message' => 'hello'})
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
records = ActiveRecord::Base.connection.select_all("SELECT * FROM messages_unmapped").to_a
|
|
111
|
+
|
|
112
|
+
assert_equal 1, records.size
|
|
113
|
+
assert_equal 'hello', records.first['message']
|
|
114
|
+
# The 'status' column is not mapped, so it should use the default value defined in the database schema
|
|
115
|
+
assert_equal 'default_status', records.first['status']
|
|
116
|
+
end
|
|
117
|
+
|
|
83
118
|
class Fallback < self
|
|
84
119
|
def test_simple
|
|
85
120
|
d = create_driver
|
|
@@ -91,10 +126,10 @@ class SqlOutputTest < Test::Unit::TestCase
|
|
|
91
126
|
|
|
92
127
|
default_table = d.instance.instance_variable_get(:@default_table)
|
|
93
128
|
model = default_table.instance_variable_get(:@model)
|
|
94
|
-
mock(model).import(anything).at_least(1) do
|
|
129
|
+
mock(model).import(anything, anything).at_least(1) do
|
|
95
130
|
raise ActiveRecord::Import::MissingColumnError.new("dummy_table", "dummy_column")
|
|
96
131
|
end
|
|
97
|
-
mock(default_table).one_by_one_import(anything)
|
|
132
|
+
mock(default_table).one_by_one_import(anything, anything)
|
|
98
133
|
end
|
|
99
134
|
end
|
|
100
135
|
|
|
@@ -108,10 +143,10 @@ class SqlOutputTest < Test::Unit::TestCase
|
|
|
108
143
|
|
|
109
144
|
default_table = d.instance.instance_variable_get(:@default_table)
|
|
110
145
|
model = default_table.instance_variable_get(:@model)
|
|
111
|
-
mock(model).import([anything, anything]).once do
|
|
146
|
+
mock(model).import(anything, [anything, anything]).once do
|
|
112
147
|
raise ActiveRecord::Import::MissingColumnError.new("dummy_table", "dummy_column")
|
|
113
148
|
end
|
|
114
|
-
mock(model).import([anything]).times(12) do
|
|
149
|
+
mock(model).import(anything, [anything]).times(12) do
|
|
115
150
|
raise StandardError
|
|
116
151
|
end
|
|
117
152
|
assert_equal(5, default_table.instance_variable_get(:@num_retries))
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-sql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: fluentd
|
|
@@ -31,19 +30,39 @@ dependencies:
|
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
31
|
version: '2'
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
33
|
+
name: ostruct
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
36
35
|
requirements:
|
|
37
36
|
- - "~>"
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '6
|
|
38
|
+
version: '0.6'
|
|
40
39
|
type: :runtime
|
|
41
40
|
prerelease: false
|
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
42
|
requirements:
|
|
44
43
|
- - "~>"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0.6'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: activerecord
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
45
51
|
- !ruby/object:Gem::Version
|
|
46
52
|
version: '6.1'
|
|
53
|
+
- - "<"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '8.2'
|
|
56
|
+
type: :runtime
|
|
57
|
+
prerelease: false
|
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '6.1'
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '8.2'
|
|
47
66
|
- !ruby/object:Gem::Dependency
|
|
48
67
|
name: activerecord-import
|
|
49
68
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -157,7 +176,6 @@ homepage: https://github.com/fluent/fluent-plugin-sql
|
|
|
157
176
|
licenses:
|
|
158
177
|
- Apache-2.0
|
|
159
178
|
metadata: {}
|
|
160
|
-
post_install_message:
|
|
161
179
|
rdoc_options: []
|
|
162
180
|
require_paths:
|
|
163
181
|
- lib
|
|
@@ -172,8 +190,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
172
190
|
- !ruby/object:Gem::Version
|
|
173
191
|
version: '0'
|
|
174
192
|
requirements: []
|
|
175
|
-
rubygems_version:
|
|
176
|
-
signing_key:
|
|
193
|
+
rubygems_version: 4.0.10
|
|
177
194
|
specification_version: 4
|
|
178
195
|
summary: SQL input/output plugin for Fluentd event collector
|
|
179
|
-
test_files:
|
|
196
|
+
test_files:
|
|
197
|
+
- test/fixtures/schema.rb
|
|
198
|
+
- test/helper.rb
|
|
199
|
+
- test/plugin/test_in_sql.rb
|
|
200
|
+
- test/plugin/test_in_sql_with_custom_time.rb
|
|
201
|
+
- test/plugin/test_in_sql_with_state_file.rb
|
|
202
|
+
- test/plugin/test_out_sql.rb
|