Skip to content

Commit

Permalink
[Fix] [sink elasticsearch] Fix the issue of sink-es saveMode conflict…
Browse files Browse the repository at this point in the history
…ing with Elasticsearch's automatic index creation apache#7430
  • Loading branch information
jw-itq committed Aug 21, 2024
1 parent ac87ba0 commit 1d833a3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ public enum DataSaveMode {
CUSTOM_PROCESSING,

// When there exist data, an error will be reported
ERROR_WHEN_DATA_EXISTS
ERROR_WHEN_DATA_EXISTS,

// Ignore
IGNORE
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void handleSchemaSaveMode() {
case ERROR_WHEN_SCHEMA_NOT_EXIST:
errorWhenSchemaNotExist();
break;
case IGNORE:
break;
default:
throw new UnsupportedOperationException("Unsupported save mode: " + schemaSaveMode);
}
Expand All @@ -91,6 +93,8 @@ public void handleDataSaveMode() {
case ERROR_WHEN_DATA_EXISTS:
errorWhenDataExists();
break;
case IGNORE:
break;
default:
throw new UnsupportedOperationException("Unsupported save mode: " + dataSaveMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ public enum SchemaSaveMode {

// Error will be reported when the table does not exist
ERROR_WHEN_SCHEMA_NOT_EXIST,

// Ignore
IGNORE
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.apache.seatunnel.api.sink.DataSaveMode.APPEND_DATA;
import static org.apache.seatunnel.api.sink.DataSaveMode.DROP_DATA;
import static org.apache.seatunnel.api.sink.DataSaveMode.ERROR_WHEN_DATA_EXISTS;
import static org.apache.seatunnel.api.sink.DataSaveMode.IGNORE;

public class SinkConfig {

Expand Down Expand Up @@ -80,7 +81,7 @@ public class SinkConfig {
Options.key("data_save_mode")
.singleChoice(
DataSaveMode.class,
Arrays.asList(DROP_DATA, APPEND_DATA, ERROR_WHEN_DATA_EXISTS))
Arrays.asList(DROP_DATA, APPEND_DATA, ERROR_WHEN_DATA_EXISTS, IGNORE))
.defaultValue(APPEND_DATA)
.withDescription("data_save_mode");
}

0 comments on commit 1d833a3

Please sign in to comment.