Skip to content

Commit 20bd377

Browse files
xinlian12Copilot
andcommitted
fix: use Integer.class for SELECT VALUE COUNT aggregate serializer test
SELECT VALUE COUNT(1) returns a scalar integer, so use Integer.class instead of ObjectNode.class as the result type. ObjectNode.class fails because ValueUnwrapCosmosItemSerializer extracts the _value field and cannot convert the resulting integer to ObjectNode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5b407c8 commit 20bd377

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemSerializerTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,18 +764,20 @@ public void queryWithAggregateAndCustomSerializer() {
764764
// results (e.g., COUNT) are not full documents and cannot be deserialized
765765
// by the envelope-wrapping serializer. The test still validates that the
766766
// client-level custom serializer does not leak into the internal query pipeline.
767+
// SELECT VALUE COUNT(1) returns a scalar integer, so use Integer.class.
767768
CosmosQueryRequestOptions queryRequestOptions = new CosmosQueryRequestOptions()
768769
.setCustomItemSerializer(CosmosItemSerializer.DEFAULT_SERIALIZER);
769770

770-
List<ObjectNode> results = container
771+
List<Integer> results = container
771772
.queryItems(
772773
"SELECT VALUE COUNT(1) FROM c WHERE c.mypk = '" + pkValue + "'",
773774
queryRequestOptions,
774-
ObjectNode.class)
775+
Integer.class)
775776
.stream().collect(Collectors.toList());
776777

777778
assertThat(results).isNotNull();
778779
assertThat(results).hasSize(1);
780+
assertThat(results.get(0)).isEqualTo(3);
779781
} finally {
780782
for (String id : createdIds) {
781783
try {

0 commit comments

Comments
 (0)