fix(dynamodb): count the hash key conditions of every OR branch for a PartiQL ORDER BY (#8558)

A PartiQL ORDER BY now counts the hash key conditions inside every OR
branch. An OR whose branches each name the partition key, such as
(pk = 'a' AND x = 1) OR (pk = 'b' AND x = 2), reads more than one
partition, so it needs the partition key in ORDER BY, and an OR with a
branch that names none still counts no hash key condition.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-16 07:16:52 -04:00
1 parent e47747845e
commit 18d04ded17
2 files changed
+23 -2

No files matched your search

@@ -264,6 +264,16 @@ class DynamoDbPartiQLDocumentedSyntaxIntegrationTest {
.statusCode(400)
.body("message", equalTo("Must have hash key in ORDER BY clause when more than one hash key condition"
+ " specified in WHERE clause."));
statement(select + "WHERE (pk = 'o' AND Total = 1) OR (pk = 'p' AND Total = 2) ORDER BY sk")
.statusCode(400)
.body("message", equalTo("Must have hash key in ORDER BY clause when more than one hash key condition"
+ " specified in WHERE clause."));
statement(select + "WHERE (pk = 'o' AND Total = 1) OR Total = 2 ORDER BY sk")
.statusCode(400)
.body("message", equalTo("Must have at least one non-optional hash key condition in WHERE clause"
+ " when using ORDER BY clause."));
statement(select + "WHERE (pk = 'o' AND Total = 1) OR (pk = 'p' AND Total = 2) ORDER BY pk")
.statusCode(200);
}
@Test