0
0
DynamoDBquery~20 mins

Filter expressions in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Filter Expression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Filter expression with attribute_exists
Given a DynamoDB table with items having attributes id and status, what will be the output of this filter expression?

FilterExpression: "attribute_exists(status) AND status = :val"

with :val set to "active"?
AReturns all items regardless of the <code>status</code> attribute.
BReturns only items where the attribute <code>status</code> exists and its value is exactly "active".
CReturns items where <code>status</code> does not exist or is "active".
DReturns items where <code>status</code> exists but its value is not "active".
Attempts:
2 left
💡 Hint
Think about what attribute_exists means and how it combines with the equality check.
query_result
intermediate
2:00remaining
Using begins_with in filter expressions
What will be the result of this filter expression on a DynamoDB table with a username attribute?

FilterExpression: "begins_with(username, :prefix)"

with :prefix set to "user"?
AReturns items where the <code>username</code> ends with "user".
BReturns items where the <code>username</code> contains "user" anywhere.
CReturns items where the <code>username</code> starts with "user".
DReturns items where the <code>username</code> is exactly "user".
Attempts:
2 left
💡 Hint
Remember what the function begins_with checks in DynamoDB.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this filter expression
Which option contains a syntax error in the DynamoDB filter expression?

Expression: FilterExpression: "status = :val AND (attribute_exists(age) OR age > :minAge"

Assume :val and :minAge are defined.
AMissing closing parenthesis in the filter expression causes a syntax error.
BUsing <code>attribute_exists</code> inside parentheses is not allowed.
CUsing comparison operators like <code>></code> in filter expressions is not allowed.
DUsing <code>AND</code> and <code>OR</code> together is invalid syntax.
Attempts:
2 left
💡 Hint
Check if all parentheses are properly closed.
optimization
advanced
2:00remaining
Optimizing filter expressions for performance
Which filter expression is more efficient for filtering items where score is between 50 and 100 inclusive in DynamoDB?
AFilterExpression: "score BETWEEN :min AND :max" with <code>:min=50</code> and <code>:max=100</code>
BFilterExpression: "score >= :min AND score <= :max" with <code>:min=50</code> and <code>:max=100</code>
CFilterExpression: "score > :min AND score < :max" with <code>:min=49</code> and <code>:max=101</code>
DFilterExpression: "score IN (:min, :max)" with <code>:min=50</code> and <code>:max=100</code>
Attempts:
2 left
💡 Hint
Consider which expression is simpler and uses built-in operators.
🧠 Conceptual
expert
2:00remaining
Understanding filter expressions impact on read capacity
Which statement best describes how filter expressions affect DynamoDB read capacity units (RCUs) when scanning a table?
AFilter expressions cause DynamoDB to read only matching items, greatly reducing RCUs.
BFilter expressions reduce the number of items read from the table, lowering RCUs consumed.
CFilter expressions increase RCUs consumed because they add extra processing on the server.
DFilter expressions do not reduce the number of items read; they only filter results after reading, so RCUs consumed remain the same.
Attempts:
2 left
💡 Hint
Think about when filtering happens during a scan operation.