Improve Scan response type based on Select option and projected attributes
Closed this issue · 0 comments
ThomasAribart commented
There are a lot of edge cases based on the presence of an index, wether it is local or global, and what attributes are projected.
Here's a recap of the scan Select
JS Docs:
Possible values are ALL_ATTRIBUTES
, ALL_PROJECTED_ATTRIBUTES
, COUNT
and SPECIFIC_ATTRIBUTE
.
By default (no index, no projection expression), Select value is ALL_ATTRIBUTES
, ALL_PROJECTED_ATTRIBUTES
is not a valid Select option, and SPECIFIC_ATTRIBUTE
can contain any attribute.
If a local Index
is specified:
ALL_ATTRIBUTES
is possible: DynamoDB will either get attributes from the index if all attributes are projected, either refetch them from the parent table.ALL_PROJECTED_ATTRIBUTES
becomes a valid Select option, that should impact the responseItems
typeSPECIFIC_ATTRIBUTE
can contain any attribute (to confirm), but at a performance cost if attributes are not projected. It should also impact the responseItems
type.COUNT
is always a valid option
If a global Index
is specified:
ALL_ATTRIBUTES
is possible ONLY IF all attributes are projected. Otherwise, it should lead to an error (to confirm).ALL_PROJECTED_ATTRIBUTES
becomes a valid Select option, that should impact the responseItems
typeSPECIFIC_ATTRIBUTE
MUST contain only projected attribute (to confirm)COUNT
is always a valid option
If a ProjectionExpression
is specified:
ALL_ATTRIBUTES
,ALL_PROJECTED_ATTRIBUTES
andCOUNT
are NOT valid Select optionSPECIFIC_ATTRIBUTES
is the only valid option and is the default value. If an index is specified, we observe the same pattern as above (MUST be projected attribute if index is global, CAN be non-projected attribute if index is local, but at a performance cost).