This is an automated email from the ASF dual-hosted git repository.

vjasani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/phoenix-adapters.git


The following commit(s) were added to refs/heads/main by this push:
     new 99f0aad  Skip setting null item on exception when using UPDATE_ONLY 
and row does not exist
99f0aad is described below

commit 99f0aadf81e6c185fe9f2540f84262cda32b93c3
Author: Palash Chauhan <[email protected]>
AuthorDate: Fri Jan 30 19:07:49 2026 -0800

    Skip setting null item on exception when using UPDATE_ONLY and row does not 
exist
---
 .../java/org/apache/phoenix/ddb/service/utils/DMLUtils.java   |  6 ++++--
 .../src/test/java/org/apache/phoenix/ddb/UpdateItemIT.java    | 11 +++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
 
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
index c778c3d..413150a 100644
--- 
a/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
+++ 
b/phoenix-ddb-rest/src/main/java/org/apache/phoenix/ddb/service/utils/DMLUtils.java
@@ -94,8 +94,10 @@ public class DMLUtils {
                         new ConditionCheckFailedException();
                     if 
(ApiMetadata.ALL_OLD.equals(returnValuesOnConditionCheckFailure) &&
                         apiOperation != ApiOperation.DELETE_ITEM) {
-                        conditionalCheckFailedException.setItem(
-                            BsonDocumentToMap.getFullItem(rawBsonDocument));
+                        if (rawBsonDocument != null) {
+                            conditionalCheckFailedException.setItem(
+                                    
BsonDocumentToMap.getFullItem(rawBsonDocument));
+                        }
                     }
                     throw conditionalCheckFailedException;
                 }
diff --git 
a/phoenix-ddb-rest/src/test/java/org/apache/phoenix/ddb/UpdateItemIT.java 
b/phoenix-ddb-rest/src/test/java/org/apache/phoenix/ddb/UpdateItemIT.java
index 1f7cbc0..344fa0d 100644
--- a/phoenix-ddb-rest/src/test/java/org/apache/phoenix/ddb/UpdateItemIT.java
+++ b/phoenix-ddb-rest/src/test/java/org/apache/phoenix/ddb/UpdateItemIT.java
@@ -366,23 +366,26 @@ public class UpdateItemIT extends UpdateItemBaseTests {
         // Condition "attribute_exists(someField)" should be false on empty 
document
         UpdateItemRequest updateRequest = 
UpdateItemRequest.builder().tableName(tableName).key(key)
                 .updateExpression("SET newField = :val")
+                .returnValuesOnConditionCheckFailure(ALL_OLD)
                 
.conditionExpression("attribute_exists(someField)").expressionAttributeValues(
                         Collections.singletonMap(":val",
                                 
AttributeValue.builder().s("shouldNotCreate").build())).build();
 
         // Both should throw ConditionalCheckFailedException
+        ConditionalCheckFailedException ddbException = null;
         try {
             dynamoDbClient.updateItem(updateRequest);
             Assert.fail("DynamoDB should throw 
ConditionalCheckFailedException");
         } catch (ConditionalCheckFailedException e) {
-            // Expected
+            ddbException = e;
         }
 
         try {
             phoenixDBClientV2.updateItem(updateRequest);
             Assert.fail("Phoenix should throw 
ConditionalCheckFailedException");
         } catch (ConditionalCheckFailedException e) {
-            // Expected
+            Assert.assertEquals(ddbException.hasItem(), e.hasItem());
+            Assert.assertEquals(ddbException.item(), e.item());
         }
 
         // Verify final state by querying both Phoenix and DDB
@@ -524,7 +527,7 @@ public class UpdateItemIT extends UpdateItemBaseTests {
         // Test ALL_NEW - should succeed
         updateRequest = 
UpdateItemRequest.builder().tableName(tableName).key(key)
             .updateExpression("SET stringField = :val")
-            
.expressionAttributeValues(expressionAttributeValues).returnValues(ReturnValue.ALL_NEW)
+            
.expressionAttributeValues(expressionAttributeValues).returnValues(ALL_NEW)
             .build();
         UpdateItemResponse dynamoResult3 = 
dynamoDbClient.updateItem(updateRequest);
         UpdateItemResponse phoenixResult3 = 
phoenixDBClientV2.updateItem(updateRequest);
@@ -608,7 +611,7 @@ public class UpdateItemIT extends UpdateItemBaseTests {
         updateRequest = 
UpdateItemRequest.builder().tableName(tableName).key(key)
             .updateExpression("SET stringField = :val")
             .expressionAttributeValues(expressionAttributeValues)
-            
.returnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
+            .returnValuesOnConditionCheckFailure(ALL_OLD)
             .build();
         UpdateItemResponse dynamoResult2 = 
dynamoDbClient.updateItem(updateRequest);
         UpdateItemResponse phoenixResult2 = 
phoenixDBClientV2.updateItem(updateRequest);

Reply via email to