Skip to content

Extend Expression Builder for Projection expressions#4310

Open
aanton-git wants to merge 4 commits intoaws:developmentfrom
aanton-git:features/projectionExpression
Open

Extend Expression Builder for Projection expressions#4310
aanton-git wants to merge 4 commits intoaws:developmentfrom
aanton-git:features/projectionExpression

Conversation

@aanton-git
Copy link

@aanton-git aanton-git commented Jan 27, 2026

Description

The AWS SDK for .NET does not currently provide a structured or fluent API for constructing ProjectionExpressions. Users must manually compose projection strings and manage ExpressionAttributeNames, which is error-prone and inconsistent with other AWS SDKs.

The Go SDK v2 includes a dedicated ProjectionBuilder as part of its DynamoDB expression package, enabling safe, composable construction of projection expressions with automatic attribute name aliasing.

Usage example

var projection = ProjectionExpressionBuilder
.New()
.WithName("parent.child[0].attribute1")
.AddName(NameBuilder.New("test.attribute2"))
.NamesList(NameBuilder.New("Attribute1"), NameBuilder.New("Attribute2"))
.Build();

Motivation and Context

This would:

  • Reduce boilerplate and runtime errors
  • Improve cross-SDK consistency
  • Align .NET DynamoDB expression ergonomics with Go SDK patterns

Testing

Breaking Changes Assessment

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • [ x] I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@aanton-git aanton-git changed the base branch from main to development January 27, 2026 12:48
@aanton-git aanton-git marked this pull request as draft January 27, 2026 12:49
…ameBuilder, update unit tests to reflect the changes, add changeLog file
@aanton-git aanton-git marked this pull request as ready for review January 29, 2026 13:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new fluent builder for DynamoDB ProjectionExpression construction in the DocumentModel expression-building framework, aiming to reduce manual string composition and make projection building consistent with existing expression builders.

Changes:

  • Introduces ProjectionExpressionBuilder to build comma-separated projection expressions with automatic attribute name aliasing.
  • Adds unit tests covering single-name, nested-path, special-character, and multi-name projection scenarios (plus empty-builder exception).
  • Adds a DevConfig entry for DynamoDBv2 release notes/version bump metadata.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
sdk/src/Services/DynamoDBv2/Custom/DocumentModel/ExpressionBuilder.cs Adds new ProjectionExpressionBuilder implementation integrated with existing ExpressionBuilder/aliasing mechanism.
sdk/test/Services/DynamoDBv2/UnitTests/Custom/ExpressionBuilderTests.cs Adds unit tests validating projection expression statements and generated ExpressionAttributeNames.
generator/.DevConfigs/264e45e8-60ef-4e07-8f70-7fb4dc554186.json Adds release metadata for the DynamoDBv2 change.

Copy link
Contributor

@GarrettBeatty GarrettBeatty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the pr description with example of how user can use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants