1

"Logs" table in DynamoDB has a simple partition key:

Partition key

It also has a global secondary index:

Global secondary index

My query statement is:

SELECT *
FROM "Logs"."CustomerIdentifier-Timestamp-index"
WHERE "CustomerIdentifier" = 'ABC123'
AND "Timestamp" >= 638014484314658930
AND "Timestamp" <= 638014484914658930
ORDER BY "Timestamp"

And the error message returned from Dynamo is "Must have at least one non-optional hash key condition in WHERE clause when using ORDER BY clause."

I would have thought that WHERE "CustomerIdentifier" = 'ABC123' meets this requirement. I am assuming that Timestamp being a range is problem, but I really don't understand why. Can someone explain a) what have I done wrong here? b) conceptually, is this type of query possible in Dynamo? and c) if so, how would I accomplish it?

maxmoore14
  • 701
  • 7
  • 26
  • If either of the lines beginning with `AND "Timestamp"` is commented out, the query runs. But I am still unsure why this is the case. – maxmoore14 Oct 17 '22 at 05:08

0 Answers0