Skip to content

Support nested collections and sets in DynamoDB controller DTOs and DSL - #1941

Open
aschenzle wants to merge 1 commit into
feat/heterogeneous-list-genefrom
feat/ddb-collections-dto-dsl-controller
Open

aschenzle wants to merge 1 commit into
feat/heterogeneous-list-genefrom
feat/ddb-collections-dto-dsl-controller

Conversation

@aschenzle

@aschenzle aschenzle commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Extends DynamoDB insertion DTOs, template extraction, reflection-based SDK writes, and the generated-test DSL in client-java/controller-api and client-java/controller to support nested documents (MAP, LIST, NULL) and sets (STRING_SET / SS, NUMBER_SET / NS) — including sets nested inside lists and maps.

Because sets are not a native JSON type, the DSL uses .ddbJson and does the corresponding parsings. The alternative to this was a rich DSL with support for nested types (methods like .numberset, .stringset, .list, etc) which seemed overkill (no other DB engine does that)

This PR is scoped to client-java/controller-api and client-java/controller. Needed to include some changes on core because of the rename of a DTO. In follow-up PRs will eliminate the DTO from core and replace with a mirrored class as discussed with Andrea.

DynamoDB binary (B) and binary set (BS) types remain unsupported and are explicitly rejected/documented.

client-java/controller-api

  • DTO & type model split
    • Replaced DynamoDbScalarTypeDto with DynamoDbKeyScalarTypeDto for primary-key metadata (DynamoDbFailedQuery, DynamoDbPrimaryKey).
    • Added DynamoDbValueTypeDto covering STRING (S), NUMBER (N), BOOLEAN (BOOL), NULL (NULL), MAP (M), LIST (L), STRING_SET (SS), and NUMBER_SET (NS), along with BINARY_WIRE_CODE ("B"), BINARY_SET_WIRE_CODE ("BS"), and fromWireCode(String) (which rejects B, BS, null, and unknown wire codes).
    • Updated DynamoDbAttributeValueDto to represent recursive trees (mapValue, listValue, setValue) and updated equals/hashCode.
  • DTO conversion & insertion keys
    • Added DynamoDbDtoUtils (fromPlainValue / toPlainValue) to convert between plain Java values (preserving BigDecimal precision and deterministic key/set ordering) and typed DynamoDbAttributeValueDto trees while rejecting empty sets, B, and BS.
    • Updated DynamoDbInsertionKeyBuilder with deterministic, length-delimited serialization for nested MAP/LIST payloads and sorted STRING_SET/NUMBER_SET values to prevent structural collisions.

client-java/controller

  • Client & handler
    • Updated ReflectionBasedDynamoDbClient to build SDK AttributeValue objects recursively for MAP, LIST, NULL, STRING_SET (ss), and NUMBER_SET (ns), validating non-empty sets.
    • Updated DynamoDbHandler (toTemplateAttribute) to delegate to DynamoDbDtoUtils.fromPlainValue(...) and skip/warn via SimpleLogger.uniqueWarn(...) when encountering unsupported attributes (B, BS, or empty/malformed sets).
  • DSL
    • Replaced .json(), .ss(), and .ns() in DynamoDbStatementDsl / DynamoDbDsl with .ddbJson(attributeName, ddbJson) (keeping .d() for scalars).
    • Implemented strict DynamoDB JSON parsing (fromDynamoDbJson) supporting nested M, L, SS, NS, S, N, BOOL, and NULL while rejecting B, BS, empty sets, non-string numbers, and malformed payloads.

Tests

  • Added unit tests: DynamoDbAttributeValueDtoTest, DynamoDbDtoUtilsTest.
  • Updated/expanded tests: DynamoDbInsertionKeyBuilderTest, ReflectionBasedDynamoDbClientTest, ReflectionBasedDynamoDbClientTableTest, DynamoDbDslTest, DynamoDbHandlerTest, DynamoDbInsertionTemplateTest, DynamoDbPrimaryKeyTest.

@aschenzle
aschenzle requested a review from jgaleotti November 18, 2026 21:04
@aschenzle
aschenzle added this pull request to stack #1942 November 18, 2026 21:04
@aschenzle
aschenzle removed this pull request from stack #1942 November 28, 2026 01:08
@aschenzle
aschenzle changed the base branch from fix/dynamodb-insertion-primary-keys to aschenzle/base-genes-plus-pk November 28, 2026 01:08
@aschenzle
aschenzle added this pull request to stack #1964 November 28, 2026 01:08
@aschenzle
aschenzle force-pushed the feat/ddb-collections-dto-dsl-controller branch 2 times, most recently from b7a8a8c to 3b9ba9c Compare December 2, 2026 06:42
@aschenzle
aschenzle removed this pull request from stack #1964 December 2, 2026 06:48
@aschenzle
aschenzle changed the base branch from aschenzle/base-genes-plus-pk to feat/heterogeneous-list-gene December 2, 2026 06:48
@aschenzle
aschenzle added this pull request to stack #1960 December 2, 2026 07:00
public Map<String, DynamoDbAttributeValueDto> mapValue;

/** List of child attributes for LIST-typed values. */
public List<DynamoDbAttributeValueDto> listValue;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this listValue the same as mapValue.values() ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, mapValue and listValue are mutually exclusive payload fields for two distinct DynamoDB types (M vs L)

@jgaleotti
jgaleotti requested a review from arcuri82 December 2, 2026 19:24
@aschenzle
aschenzle force-pushed the feat/ddb-collections-dto-dsl-controller branch from 3b9ba9c to 4ee2e46 Compare December 4, 2026 04:45
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.

2 participants