Class ProjectionExpression
java.lang.Object
software.amazon.awssdk.enhanced.dynamodb.internal.ProjectionExpression
This class represents the concept of a projection expression, which allows the user to specify which specific attributes
should be returned when a table is queried. By default, all attribute names in a projection expression are replaced with
a cleaned placeholder version of itself, prefixed with #AMZN_MAPPED.
A ProjectionExpression can return a correctly formatted projection expression string
containing placeholder names (see projectionExpressionAsString()
), as well as the expression attribute names map which
contains the mapping from the placeholder attribute name to the actual attribute name (see
expressionAttributeNames()
).
Resolving duplicates
- If the input to the ProjectionExpression contains the same attribute name in more than one place, independent of nesting level, it will be mapped to a single placeholder
- If two attributes resolves to the same placeholder name, a disambiguator is added to the placeholder in order to make it unique.
Placeholder conversion examples
- 'MyAttribute' maps to
#AMZN_MAPPED_MyAttribute
- 'MyAttribute' appears twice in input but maps to only one entry
#AMZN_MAPPED_MyAttribute
. - 'MyAttribute-1' maps to
#AMZN_MAPPED_MyAttribute_1
- 'MyAttribute-1' and 'MyAttribute.1' in the same input maps to
#AMZN_MAPPED_0_MyAttribute_1
and#AMZN_MAPPED_1_MyAttribute_1
List<NestedAttributeName> attributeNames = Arrays.asList(
NestedAttributeName.create("MyAttribute")
NestedAttributeName.create("MyAttribute.WithDot", "MyAttribute.03"),
NestedAttributeName.create("MyAttribute:03, "MyAttribute")
);
ProjectionExpression projectionExpression = ProjectionExpression.create(attributeNames);
Map<String, String> expressionAttributeNames = projectionExpression.expressionAttributeNames();
Optional<String> projectionExpressionString = projectionExpression.projectionExpressionAsString();
results in
expressionAttributeNames: {
#AMZN_MAPPED_MyAttribute : MyAttribute,
#AMZN_MAPPED_MyAttribute_WithDot : MyAttribute.WithDot}
#AMZN_MAPPED_0_MyAttribute_03 : MyAttribute.03}
#AMZN_MAPPED_1_MyAttribute_03 : MyAttribute:03}
}
and
projectionExpressionString: "#AMZN_MAPPED_MyAttribute,#AMZN_MAPPED_MyAttribute_WithDot.#AMZN_MAPPED_0_MyAttribute_03,
#AMZN_MAPPED_1_MyAttribute_03.#AMZN_MAPPED_MyAttribute"
For more information, see Projection Expressions in the Amazon DynamoDB Developer Guide.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProjectionExpression
create
(List<NestedAttributeName> nestedAttributeNames)
-
Method Details
-
create
-
expressionAttributeNames
-
projectionExpressionAsString
-