umustafi commented on a change in pull request #3438:
URL: https://github.com/apache/gobblin/pull/3438#discussion_r762350061



##########
File path: 
gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/writer/commands/BaseJdbcBufferedInserter.java
##########
@@ -51,6 +51,7 @@
   private static final Logger LOG = 
LoggerFactory.getLogger(BaseJdbcBufferedInserter.class);
 
   protected static final String INSERT_STATEMENT_PREFIX_FORMAT = "INSERT INTO 
%s.%s (%s) VALUES ";
+  protected static final String REPLACE_STATEMENT_PREFIX_FORMAT = "REPLACE 
INTO %s.%s (%s) VALUES ";

Review comment:
       Makes sense, moving this to the `MySQLBufferedInserter`

##########
File path: 
gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/writer/commands/MySqlWriterCommands.java
##########
@@ -47,14 +48,17 @@
   private static final String INFORMATION_SCHEMA_SELECT_SQL_PSTMT =
       "SELECT column_name, column_type FROM information_schema.columns WHERE 
table_schema = ? AND table_name = ?";
   private static final String COPY_INSERT_STATEMENT_FORMAT = "INSERT INTO 
%s.%s SELECT * FROM %s.%s";
+  private static final String COPY_REPLACE_STATEMENT_FORMAT = "REPLACE INTO 
%s.%s SELECT * FROM %s.%s";
   private static final String DELETE_STATEMENT_FORMAT = "DELETE FROM %s.%s";
 
   private final JdbcBufferedInserter jdbcBufferedWriter;
   private final Connection conn;
+  private final boolean replaceExistingValues;
 
   public MySqlWriterCommands(State state, Connection conn) {
     this.conn = conn;
     this.jdbcBufferedWriter = new MySqlBufferedInserter(state, conn);
+    this.replaceExistingValues = 
state.getPropAsBoolean(ConfigurationKeys.REPLACE_FOR_MYSQL_INGESTION);

Review comment:
       The place I could provide the boolean param for the ctor looks to be in 
the constructor for `JdbcWriterCommands`. It does not have much logic other 
than choosing which class to instantiate. There doesn't seem to be a large 
benefit from translating the config to a boolean one step earlier so I'll leave 
as is. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to