tkhurana commented on code in PR #1967: URL: https://github.com/apache/phoenix/pull/1967#discussion_r1746190343
########## phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKey2IT.java: ########## @@ -118,6 +137,148 @@ public void testIgnoreReturnValue() throws Exception { conn.close(); } + @Test + public void testReturnRowResult() throws Exception { + Assume.assumeTrue("Set correct result to RegionActionResult on hbase versions " + + "2.4.18+, 2.5.9+, and 2.6.0+", isSetCorrectResultEnabledOnHBase()); + + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + String sample1 = getJsonString("json/sample_01.json"); + String sample2 = getJsonString("json/sample_02.json"); + BsonDocument bsonDocument1 = RawBsonDocument.parse(sample1); + BsonDocument bsonDocument2 = RawBsonDocument.parse(sample2); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + conn.setAutoCommit(true); + String tableName = generateUniqueName(); + String ddl = "CREATE TABLE " + tableName + + "(PK1 VARCHAR, PK2 DOUBLE NOT NULL, PK3 VARCHAR, COUNTER1 DOUBLE," + + " COUNTER2 VARCHAR," + + " COL3 BSON, COL4 INTEGER, CONSTRAINT pk PRIMARY KEY(PK1, PK2, PK3))"; + conn.createStatement().execute(ddl); + createIndex(conn, tableName); + + String upsertSql = "UPSERT INTO " + tableName + " (PK1, PK2, PK3, COUNTER1, COL3, COL4)" + + " VALUES('pk000', -123.98, 'pk003', 1011.202, ?, 123) ON DUPLICATE KEY " + + "IGNORE"; + validateReturnedRowAfterUpsert(conn, upsertSql, tableName, 1011.202, null, true, + bsonDocument1, bsonDocument1, 123); + + upsertSql = + "UPSERT INTO " + tableName + " (PK1, PK2, PK3, COUNTER1) " + + "VALUES('pk000', -123.98, 'pk003', 0) ON DUPLICATE" + + " KEY IGNORE"; + validateReturnedRowAfterUpsert(conn, upsertSql, tableName, 1011.202, null, false, + null, bsonDocument1, 123); + + upsertSql = + "UPSERT INTO " + tableName + + " (PK1, PK2, PK3, COUNTER1, COUNTER2) VALUES('pk000', -123.98, " + + "'pk003', 234, 'col2_000')"; + validateReturnedRowAfterUpsert(conn, upsertSql, tableName, 234d, "col2_000", true, Review Comment: In the above example we are doing a regular upsert with returned row. -- 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: issues-unsubscr...@phoenix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org