Skip to content

Commit a8dc4b1

Browse files
author
gituser
committed
Merge branch 'hotfix_1.10_4.0.x_30263' into 1.10_release_4.0.x
2 parents 67c2378 + e8d0178 commit a8dc4b1

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/ocean/OceanbaseDialect.java renamed to oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/oceanbase/OceanbaseDialect.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package com.dtstack.flink.sql.sink.ocean;
18+
package com.dtstack.flink.sql.sink.oceanbase;
1919

2020
import com.dtstack.flink.sql.sink.rdb.dialect.JDBCDialect;
2121

@@ -50,27 +50,30 @@ public Optional<String> getUpsertStatement(String schema,
5050
String[] uniqueKeyFields,
5151
boolean allReplace) {
5252
return allReplace ?
53-
buildReplaceIntoStatement(tableName, fieldNames) :
54-
buildDuplicateUpsertStatement(tableName, fieldNames);
53+
buildReplaceIntoStatement(tableName, fieldNames) : buildDuplicateUpsertStatement(tableName, fieldNames);
5554
}
5655

57-
private Optional<String> buildDuplicateUpsertStatement(String tableName, String[] fieldsName) {
58-
String updateClause = Arrays.stream(fieldsName).map(f -> quoteIdentifier(f)
59-
+ "IFNULL(VALUES(" + quoteIdentifier(f) + ")," + quoteIdentifier(f) + ")")
60-
.collect(Collectors.joining(","));
61-
return Optional.of(getInsertIntoStatement("", tableName, fieldsName, null) +
56+
public Optional<String> buildDuplicateUpsertStatement(String tableName, String[] fieldNames) {
57+
String updateClause = Arrays
58+
.stream(fieldNames)
59+
.map(f -> quoteIdentifier(f) + "=IFNULL(VALUES(" + quoteIdentifier(f) + ")," + quoteIdentifier(f) + ")")
60+
.collect(Collectors.joining(", "));
61+
62+
return Optional.of(getInsertIntoStatement("", tableName, fieldNames, null) +
6263
" ON DUPLICATE KEY UPDATE " + updateClause
6364
);
6465
}
6566

66-
private Optional<String> buildReplaceIntoStatement(String tableName, String[] fieldsNames) {
67-
String columns = Arrays.stream(fieldsNames)
67+
public Optional<String> buildReplaceIntoStatement(String tableName, String[] fieldNames) {
68+
String columns = Arrays
69+
.stream(fieldNames)
6870
.map(this::quoteIdentifier)
69-
.collect(Collectors.joining(","));
70-
String placeholders = Arrays.stream(fieldsNames)
71+
.collect(Collectors.joining(", "));
72+
String placeholders = Arrays
73+
.stream(fieldNames)
7174
.map(f -> "?")
72-
.collect(Collectors.joining(","));
75+
.collect(Collectors.joining(", "));
7376
return Optional.of("REPLACE INTO " + quoteIdentifier(tableName) +
74-
"(" + columns + ") VALUES (" + placeholders + ")");
77+
"(" + columns + ")" + " VALUES (" + placeholders + ")");
7578
}
7679
}

oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/ocean/OceanbaseSink.java renamed to oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/oceanbase/OceanbaseSink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package com.dtstack.flink.sql.sink.ocean;
18+
package com.dtstack.flink.sql.sink.oceanbase;
1919

2020
import com.dtstack.flink.sql.sink.IStreamSinkGener;
2121
import com.dtstack.flink.sql.sink.rdb.AbstractRdbSink;

oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/ocean/table/OceanbaseSinkParser.java renamed to oceanbase/oceanbase-sink/src/main/java/com/dtstack/flink/sql/sink/oceanbase/table/OceanbaseSinkParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package com.dtstack.flink.sql.sink.ocean.table;
18+
package com.dtstack.flink.sql.sink.oceanbase.table;
1919

2020
import com.dtstack.flink.sql.sink.rdb.table.RdbSinkParser;
2121
import com.dtstack.flink.sql.table.AbstractTableInfo;

0 commit comments

Comments
 (0)