0
0
DynamoDBquery~10 mins

Querying GSI in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the index name when querying a GSI.

DynamoDB
response = table.query(IndexName=[1], KeyConditionExpression=Key('GSIKey').eq('value'))
Drag options to blanks, or click blank then click option'
A'TableName'
B'PartitionKey'
C'MyGSI'
D'PrimaryIndex'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of the GSI name.
Omitting the IndexName parameter.
Using the primary key name as the index name.
2fill in blank
medium

Complete the code to use the correct key condition expression for the GSI partition key.

DynamoDB
response = table.query(IndexName='MyGSI', KeyConditionExpression=Key('[1]').eq('value'))
Drag options to blanks, or click blank then click option'
APrimaryKey
BSortKey
CTableKey
DGSIKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table's primary key instead of the GSI key.
Using an attribute not defined in the GSI.
3fill in blank
hard

Fix the error in the query code by completing the missing parameter to specify the sort key condition.

DynamoDB
response = table.query(IndexName='MyGSI', KeyConditionExpression=Key('GSIKey').eq('value') [1] Key('GSISortKey').lt(100))
Drag options to blanks, or click blank then click option'
A|
B&
C+
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using | instead of &.
Using a comma or plus sign to combine conditions.
4fill in blank
hard

Fill both blanks to complete the query that filters results after querying the GSI.

DynamoDB
response = table.query(IndexName='MyGSI', KeyConditionExpression=Key('GSIKey').eq('value'), FilterExpression=Attr('[1]').[2]('active'))
Drag options to blanks, or click blank then click option'
AStatus
Bbegins_with
Ceq
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong attribute name.
Using a string method like contains when exact match is needed.
5fill in blank
hard

Fill all three blanks to build a query that uses a GSI, filters by attribute, and limits results.

DynamoDB
response = table.query(IndexName=[1], KeyConditionExpression=Key('GSIKey').eq('value'), FilterExpression=Attr([2]).[3]('pending'), Limit=10)
Drag options to blanks, or click blank then click option'
A'MyGSI'
B'Category'
Ceq
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the index name.
Using contains instead of eq for exact match.
Using wrong attribute name in filter.