Skip to content

Commit 3cfe8c1

Browse files
unidingzhouyq
and
zhouyq
authored
[Improve] sink mongodb schema is not required (#8887)
Co-authored-by: zhouyq <[email protected]>
1 parent 26b5529 commit 3cfe8c1

18 files changed

+1
-378
lines changed

Diff for: docs/en/connector-v2/sink/MongoDB.md

-21
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ The following table lists the field data type mapping from MongoDB BSON type to
6565
| uri | String | Yes | - | The MongoDB standard connection uri. eg. mongodb://user:password@hosts:27017/database?readPreference=secondary&slaveOk=true. |
6666
| database | String | Yes | - | The name of MongoDB database to read or write. |
6767
| collection | String | Yes | - | The name of MongoDB collection to read or write. |
68-
| schema | String | Yes | - | MongoDB's BSON and seatunnel data structure mapping. |
6968
| buffer-flush.max-rows | String | No | 1000 | Specifies the maximum number of buffered rows per batch request. |
7069
| buffer-flush.interval | String | No | 30000 | Specifies the maximum interval of buffered rows per batch request, the unit is millisecond. |
7170
| retry.max | String | No | 3 | Specifies the max number of retry if writing records to database failed. |
@@ -113,12 +112,6 @@ sink {
113112
uri = mongodb://user:[email protected]:27017
114113
database = "test"
115114
collection = "test"
116-
schema = {
117-
fields {
118-
_id = string
119-
c_bigint = bigint
120-
}
121-
}
122115
}
123116
}
124117
```
@@ -175,13 +168,6 @@ sink {
175168
collection = "users"
176169
buffer-flush.max-rows = 2000
177170
buffer-flush.interval = 1000
178-
schema = {
179-
fields {
180-
_id = string
181-
id = bigint
182-
status = string
183-
}
184-
}
185171
}
186172
}
187173
```
@@ -208,13 +194,6 @@ sink {
208194
collection = "users"
209195
upsert-enable = true
210196
primary-key = ["name","status"]
211-
schema = {
212-
fields {
213-
_id = string
214-
name = string
215-
status = string
216-
}
217-
}
218197
}
219198
}
220199
```

Diff for: seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/sink/MongodbSinkFactory.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.seatunnel.connectors.seatunnel.mongodb.sink;
1919

2020
import org.apache.seatunnel.api.configuration.util.OptionRule;
21-
import org.apache.seatunnel.api.options.ConnectorCommonOptions;
2221
import org.apache.seatunnel.api.table.factory.Factory;
2322
import org.apache.seatunnel.api.table.factory.TableSinkFactory;
2423
import org.apache.seatunnel.connectors.seatunnel.mongodb.config.MongodbConfig;
@@ -37,11 +36,7 @@ public String factoryIdentifier() {
3736
@Override
3837
public OptionRule optionRule() {
3938
return OptionRule.builder()
40-
.required(
41-
MongodbConfig.URI,
42-
MongodbConfig.DATABASE,
43-
MongodbConfig.COLLECTION,
44-
ConnectorCommonOptions.SCHEMA)
39+
.required(MongodbConfig.URI, MongodbConfig.DATABASE, MongodbConfig.COLLECTION)
4540
.optional(
4641
MongodbConfig.BUFFER_FLUSH_INTERVAL,
4742
MongodbConfig.BUFFER_FLUSH_MAX_ROWS,

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/cdcIT/fake_cdc_sink_mongodb.conf

-7
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,5 @@ sink {
6464
database = "test_db"
6565
collection = "test_cdc_table"
6666
primary-key = ["c_int"]
67-
schema = {
68-
fields {
69-
c_int = int
70-
name = string
71-
score = int
72-
}
73-
}
7467
}
7568
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/cdcIT/fake_cdc_upsert_sink_mongodb.conf

-7
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,5 @@ sink {
7777
collection = "test_cdc_table"
7878
upsert-enable = true
7979
primary-key = ["c_int"]
80-
schema = {
81-
fields {
82-
c_int = int
83-
name = string
84-
score = int
85-
}
86-
}
8780
}
8881
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/compatibleParametersIT/fake_source_to_update_mongodb.conf

-28
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,5 @@ sink {
7171
// compatible parameters
7272
upsert-key = ["c_int"]
7373
plugin_input = "mongodb_table"
74-
schema = {
75-
fields {
76-
c_map = "map<string, string>"
77-
c_array = "array<int>"
78-
c_string = string
79-
c_boolean = boolean
80-
c_int = int
81-
c_bigint = bigint
82-
c_double = double
83-
c_bytes = bytes
84-
c_date = date
85-
c_decimal = "decimal(33, 18)"
86-
c_timestamp = timestamp
87-
c_row = {
88-
c_map = "map<string, string>"
89-
c_array = "array<int>"
90-
c_string = string
91-
c_boolean = boolean
92-
c_int = int
93-
c_bigint = bigint
94-
c_double = double
95-
c_bytes = bytes
96-
c_date = date
97-
c_decimal = "decimal(33, 18)"
98-
c_timestamp = timestamp
99-
}
100-
}
101-
}
10274
}
10375
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/compatibleParametersIT/mongodb_matchQuery_source_to_assert.conf

-20
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,5 @@ sink {
6666
database = "test_db"
6767
collection = "test_match_op_result_db"
6868
plugin_input = "mongodb_table"
69-
schema = {
70-
fields {
71-
c_map = "map<string, string>"
72-
c_array = "array<int>"
73-
c_string = string
74-
c_boolean = boolean
75-
c_int = int
76-
c_bigint = bigint
77-
c_double = double
78-
c_row = {
79-
c_map = "map<string, string>"
80-
c_array = "array<int>"
81-
c_string = string
82-
c_boolean = boolean
83-
c_int = int
84-
c_bigint = bigint
85-
c_double = double
86-
}
87-
}
88-
}
8969
}
9070
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/fake_source_to_mongodb.conf

-28
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,5 @@ sink {
6767
uri = "mongodb://e2e_mongodb:27017/test_db?retryWrites=true"
6868
database = "test_db"
6969
collection = "test_source_sink_table"
70-
schema = {
71-
fields {
72-
c_map = "map<string, string>"
73-
c_array = "array<int>"
74-
c_string = string
75-
c_boolean = boolean
76-
c_int = int
77-
c_bigint = bigint
78-
c_double = double
79-
c_bytes = bytes
80-
c_date = date
81-
c_decimal = "decimal(33, 18)"
82-
c_timestamp = timestamp
83-
c_row = {
84-
c_map = "map<string, string>"
85-
c_array = "array<int>"
86-
c_string = string
87-
c_boolean = boolean
88-
c_int = int
89-
c_bigint = bigint
90-
c_double = double
91-
c_bytes = bytes
92-
c_date = date
93-
c_decimal = "decimal(33, 18)"
94-
c_timestamp = timestamp
95-
}
96-
}
97-
}
9870
}
9971
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/flatIT/fake_source_to_flat_mongodb.conf

-28
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,5 @@ sink {
6767
database = "test_db"
6868
collection = "test_flat_table"
6969
plugin_input = "mongodb_table"
70-
schema = {
71-
fields {
72-
c_map = "map<string, string>"
73-
c_array = "array<int>"
74-
c_string = string
75-
c_boolean = boolean
76-
c_int = int
77-
c_bigint = bigint
78-
c_double = double
79-
c_bytes = bytes
80-
c_date = date
81-
c_decimal = "decimal(33, 18)"
82-
c_timestamp = timestamp
83-
c_row = {
84-
c_map = "map<string, string>"
85-
c_array = "array<int>"
86-
c_string = string
87-
c_boolean = boolean
88-
c_int = int
89-
c_bigint = bigint
90-
c_double = double
91-
c_bytes = bytes
92-
c_date = date
93-
c_decimal = "decimal(33, 18)"
94-
c_timestamp = timestamp
95-
}
96-
}
97-
}
9870
}
9971
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/matchIT/mongodb_matchProjection_source_to_assert.conf

-20
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,5 @@ sink {
6464
database = "test_db"
6565
collection = "test_match_op_result_db"
6666
plugin_input = "mongodb_table"
67-
schema = {
68-
fields {
69-
c_map = "map<string, string>"
70-
c_array = "array<int>"
71-
c_string = string
72-
c_boolean = boolean
73-
c_int = int
74-
c_double = double
75-
c_row = {
76-
c_map = "map<string, string>"
77-
c_array = "array<int>"
78-
c_string = string
79-
c_boolean = boolean
80-
c_int = int
81-
c_bigint = bigint
82-
c_double = double
83-
}
84-
}
85-
}
8667
}
87-
8868
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/matchIT/mongodb_matchQuery_source_to_assert.conf

-20
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,5 @@ sink {
6565
database = "test_db"
6666
collection = "test_match_op_result_db"
6767
plugin_input = "mongodb_table"
68-
schema = {
69-
fields {
70-
c_map = "map<string, string>"
71-
c_array = "array<int>"
72-
c_string = string
73-
c_boolean = boolean
74-
c_int = int
75-
c_bigint = bigint
76-
c_double = double
77-
c_row = {
78-
c_map = "map<string, string>"
79-
c_array = "array<int>"
80-
c_string = string
81-
c_boolean = boolean
82-
c_int = int
83-
c_bigint = bigint
84-
c_double = double
85-
}
86-
}
87-
}
8868
}
8969
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/mongodb_double_value.conf

-20
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,5 @@ sink {
6464
database = "test_db"
6565
collection = "test_double_op_db_result"
6666
plugin_input = "mongodb_table"
67-
schema = {
68-
fields {
69-
c_map = "map<string, string>"
70-
c_array = "array<int>"
71-
c_string = string
72-
c_boolean = boolean
73-
c_int = int
74-
c_bigint = bigint
75-
c_double = double
76-
c_row = {
77-
c_map = "map<string, string>"
78-
c_array = "array<int>"
79-
c_string = string
80-
c_boolean = boolean
81-
c_int = int
82-
c_bigint = bigint
83-
c_double = double
84-
}
85-
}
86-
}
8767
}
8868
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/mongodb_null_value.conf

-21
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,5 @@ sink {
6464
uri = "mongodb://e2e_mongodb:27017/test_db?retryWrites=true"
6565
database = "test_db"
6666
collection = "test_null_op_db_result"
67-
schema = {
68-
fields {
69-
c_map = "map<string, string>"
70-
c_array = "array<int>"
71-
c_string = string
72-
c_boolean = boolean
73-
c_int = int
74-
c_bigint = bigint
75-
c_double = double
76-
c_row = {
77-
c_map = "map<string, string>"
78-
c_array = "array<int>"
79-
c_string = string
80-
c_boolean = boolean
81-
c_int = int
82-
c_bigint = bigint
83-
c_double = double
84-
}
85-
}
86-
}
8767
}
88-
8968
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/splitIT/mongodb_split_key_source_to_assert.conf

-20
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,5 @@ sink {
6565
database = "test_db"
6666
collection = "test_split_op_result_db"
6767
plugin_input = "mongodb_table"
68-
schema = {
69-
fields {
70-
c_map = "map<string, string>"
71-
c_array = "array<int>"
72-
c_string = string
73-
c_boolean = boolean
74-
c_int = int
75-
c_bigint = bigint
76-
c_double = double
77-
c_row = {
78-
c_map = "map<string, string>"
79-
c_array = "array<int>"
80-
c_string = string
81-
c_boolean = boolean
82-
c_int = int
83-
c_bigint = bigint
84-
c_double = double
85-
}
86-
}
87-
}
8868
}
8969
}

Diff for: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/resources/splitIT/mongodb_split_size_source_to_assert.conf

-20
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,6 @@ sink {
6666
database = "test_db"
6767
collection = "test_split_op_result_db"
6868
plugin_input = "mongodb_table"
69-
schema = {
70-
fields {
71-
c_map = "map<string, string>"
72-
c_array = "array<int>"
73-
c_string = string
74-
c_boolean = boolean
75-
c_int = int
76-
c_bigint = bigint
77-
c_double = double
78-
c_row = {
79-
c_map = "map<string, string>"
80-
c_array = "array<int>"
81-
c_string = string
82-
c_boolean = boolean
83-
c_int = int
84-
c_bigint = bigint
85-
c_double = double
86-
}
87-
}
88-
}
8969
}
9070

9171
}

0 commit comments

Comments
 (0)