Bird
0
0

You wrote a query with KeyConditionExpression 'PK = :pk and SK > :sk' but get an error. What is a likely cause?

medium📝 Debug Q6 of 15
DynamoDB - Access Patterns and Query Optimization
You wrote a query with KeyConditionExpression 'PK = :pk and SK > :sk' but get an error. What is a likely cause?
AUsing a greater than operator on the sort key is invalid
BThe query must use begins_with instead of >
CThe partition key value :pk is missing or incorrect
DThe sort key attribute is not defined in the table
Step-by-Step Solution
Solution:
  1. Step 1: Check KeyConditionExpression requirements

    Partition key must be specified exactly in a query; missing or wrong value causes errors.
  2. Step 2: Evaluate options

    The partition key value :pk is missing or incorrect is likely because without a valid partition key, the query fails. Using a greater than operator on the sort key is invalid is false; > is valid on sort key. The sort key attribute is not defined in the table would cause different errors. The query must use begins_with instead of > is incorrect; > is allowed.
  3. Final Answer:

    The partition key value :pk is missing or incorrect -> Option C
  4. Quick Check:

    Partition key required and correct = D [OK]
Quick Trick: Partition key must be exact and present in query [OK]
Common Mistakes:
MISTAKES
  • Using > on partition key
  • Omitting partition key value
  • Confusing query with scan

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes