[ 
https://issues.apache.org/jira/browse/GOBBLIN-1584?focusedWorklogId=690394&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-690394
 ]

ASF GitHub Bot logged work on GOBBLIN-1584:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Dec/21 00:07
            Start Date: 04/Dec/21 00:07
    Worklog Time Spent: 10m 
      Work Description: 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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 690394)
    Time Spent: 1h 40m  (was: 1.5h)

> Add Replace Logic To Mysql Writer
> ---------------------------------
>
>                 Key: GOBBLIN-1584
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1584
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-service
>            Reporter: Urmi Mustafi
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> We only supportĀ {{insertion}} of new values into tables, not 
> {{{}update/upsert{}}}. If you run an ingestion job with a record containing a 
> record with the same primary key the whole job will fail because of the 
> duplicate entry. We don't expect ingestion jobs to always containĀ _only new_ 
> records, so we should handle duplicate entries, ingestion of data already in 
> the table or updates to old values. The insert vs. replace logic should be 
> configurable to the user as well.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to