0
0
DynamoDBquery~10 mins

Parallel scan 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 start a parallel scan with 4 segments.

DynamoDB
response = table.scan(Segment=[1], TotalSegments=4)
Drag options to blanks, or click blank then click option'
A1
B4
C5
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using Segment=4 which is out of range.
Starting Segment count at 1 instead of 0.
2fill in blank
medium

Complete the code to specify the total number of segments for a parallel scan.

DynamoDB
response = table.scan(Segment=2, TotalSegments=[1])
Drag options to blanks, or click blank then click option'
A4
B2
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Setting TotalSegments less than or equal to Segment.
Using TotalSegments=1 for parallel scan which defeats the purpose.
3fill in blank
hard

Fix the error in the parallel scan code by completing the missing parameter.

DynamoDB
response = table.scan(Segment=1, TotalSegments=3, [1]=True)
Drag options to blanks, or click blank then click option'
AParallelScan
BConsistentRead
CExclusiveStartKey
DReturnConsumedCapacity
Attempts:
3 left
💡 Hint
Common Mistakes
Using ParallelScan as a parameter which does not exist.
Confusing ExclusiveStartKey with consistency setting.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps segment numbers to their scan results.

DynamoDB
results = {segment: table.scan(Segment=[1], TotalSegments=[2]) for segment in range(4)}
Drag options to blanks, or click blank then click option'
Asegment
B4
C3
Dsegment + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using segment + 1 for Segment which goes out of range.
Setting TotalSegments less than the range count.
5fill in blank
hard

Fill all three blanks to filter scan results for items with attribute 'status' equal to 'active' in each segment.

DynamoDB
filtered = {seg: [item for item in table.scan(Segment=[1], TotalSegments=[2])['Items'] if item.get('[3]') == 'active'] for seg in range(3)}
Drag options to blanks, or click blank then click option'
Aseg
B3
Cstatus
Dsegment
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'segment' instead of 'seg' causing undefined variable error.
Filtering by wrong attribute name.