tkhurana commented on a change in pull request #1183:
URL: https://github.com/apache/phoenix/pull/1183#discussion_r602450315



##########
File path: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java
##########
@@ -614,6 +614,48 @@ public void 
testRowsCreatedViaUpsertOnDuplicateKeyShouldNotBeReturnedInQueryIfNo
         conn.close();
     }
 
+    @Test
+    public void testOnDupAndUpsertInSameCommitBatch() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String tableName = generateUniqueName();
+        try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+            String ddl = "create table " + tableName + "(pk varchar primary 
key, counter1 bigint, counter2 smallint)";
+            conn.createStatement().execute(ddl);
+            createIndex(conn, tableName);
+
+            // row doesn't exist
+            conn.createStatement().execute(String.format("UPSERT INTO %s 
VALUES('a',0,1)", tableName));
+            conn.createStatement().execute(String.format(
+                "UPSERT INTO %s VALUES('a',1,1) ON DUPLICATE KEY UPDATE 
counter1 = counter1 + 2", tableName));
+            conn.commit();
+            assertRow(conn, tableName, "a", 2, 1);
+
+            // row exists
+            conn.createStatement().execute(String.format("UPSERT INTO %s 
VALUES('a', 7, 4)", tableName));
+            conn.createStatement().execute(String.format(
+                "UPSERT INTO %s VALUES('a',1,1) ON DUPLICATE KEY UPDATE 
counter1 = counter1 + 2", tableName));
+            conn.commit();
+            assertRow(conn, tableName, "a", 9, 4);
+
+            // partial update
+            conn.createStatement().execute(String.format(
+                "UPSERT INTO %s (pk, counter2) VALUES('a',100) ON DUPLICATE 
KEY UPDATE counter1 = counter1 + 2", tableName));
+            conn.createStatement().execute(String.format(
+                "UPSERT INTO %s (pk, counter2) VALUES ('a',125)", tableName));
+            conn.commit();
+            assertRow(conn, tableName, "a", 11, 125);

Review comment:
       That is actually local index




-- 
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.

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


Reply via email to