Why querying with ORDER BY fails in DynamoDb?

Viewed 24

I have a query where I ORDER BY expected_delivery value which is a number (UNIX timestamp) but it fails with this error:

ValidationException: Must have at least one non-optional hash key condition in WHERE clause when using ORDER BY clause.

Here is the query:

SELECT * FROM "transactions"."composite_pk_1-index" 
WHERE begins_with(composite_pk_1, '0#3#435634652#69992528') 
ORDER BY expected_delivery ASC

if I run it without the ORDER BY part then it runs successfully and returns data:

SELECT * FROM "transactions"."composite_pk_1-index" 
WHERE begins_with(composite_pk_1, '0#3#435634652#69992528') 

I tried adding other conditions in the query but it keeps returning the same error. Obviously the error is not stating what's the problem but I dont get it what it is.

Can someone help? I am new to DynamoDB.

0 Answers
Related