Skip to content

feat: add DynamoDB query support to DynamoDBRead - #694

Open
nasudadada wants to merge 2 commits into
BrainPad:masterfrom
nasudadada:feature/529-dynamodb-query-support
Open

feat: add DynamoDB query support to DynamoDBRead#694
nasudadada wants to merge 2 commits into
BrainPad:masterfrom
nasudadada:feature/529-dynamodb-query-support

Conversation

@nasudadada

Copy link
Copy Markdown
Contributor

Brief

Extend DynamoDBRead to support the DynamoDB query operation in addition to scan,
so users can efficiently retrieve items by partition key (and optionally sort key)
instead of always scanning the whole table.

Closes #529

Key Changes

  • Added partition_key / partition_value / sort_key / sort_value arguments to
    DynamoDBRead
  • When partition_key/partition_value are specified, a query operation is used
    (equality condition only, optionally narrowed by sort_key/sort_value)
  • When neither is specified, falls back to scan — fully backward compatible with
    existing scenarios
  • Migrated DynamoDBRead to the pydantic Arguments pattern (table_name/file_name
    are now required fields, file_format is a Literal["csv", "jsonl"])
  • Added a model_validator to reject invalid combinations (e.g. sort_key without
    partition_key, or a key name given without its matching value)
  • Extracted a shared _paginate() generator used by both _scan_table and the new
    _query_table, to avoid duplicating the LastEvaluatedKey pagination loop

Test

Confirmed

  • Added/updated unit tests in tests/scenario/extract/test_aws.py covering: scan
    (regression), query by partition key only, query by partition key + sort key,
    pagination for both scan and query, and the new validation error cases
  • Ran the full local CI-equivalent checks: pflake8, black --check, isort --check,
    bandit --severity-level high, lint-imports, pytest --cov

Extend DynamoDBRead to use the DynamoDB query operation when
partition_key/partition_value (and optionally sort_key/sort_value)
are specified, instead of always scanning the whole table. Falls
back to scan when no key is specified, so existing scenarios keep
working unchanged.

Closes BrainPad#529
DynamoDBRead.Arguments inherited the required `region: str` from
BaseAws.Arguments, so omitting region raised a pydantic ValidationError
even though the docs describe it as optional (falls back to the
default AWS region). Override it as optional, same as BaseS3.Arguments
does.
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.

Support DynamoDBRead query operation (partition key / sort key filtering)

1 participant