I have a super simple DynamoDB Table:
CurrencyExchange:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'MyTable'
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: 'RDate'
AttributeType: 'S'
KeySchema:
- AttributeName: 'RDate'
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: DateIndex
KeySchema:
- AttributeName: 'RDate'
KeyType: HASH
Projection:
ProjectionType: ALL
And all I want to do is find the highest key value. I don't have a query value to use as condition, so I tried with
$iteratorParameters = [
'TableName' => 'MyTable',
'Limit' => 1,
'IndexName' => 'DateIndex',
'ScanIndexForward' => true
];
$result = DynamoDbFacade::query($iteratorParameters);
but I get
{
"__type":"com.amazon.coral.validate#ValidationException",
"message":"Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."
}
I can use a KeyConditions
with one of these operators [IN, NULL, BETWEEN, LT, NOT_CONTAINS, EQ, GT, NOT_NULL, NE, LE, BEGINS_WITH, GE, CONTAINS]
but if I do
$iteratorParameters = [
'TableName' => 'MyTable',
'Limit' => 1,
'KeyConditions' => [
'RDate' => [
'ComparisonOperator' => 'NOT_NULL'
],
],
'IndexName' => 'DateIndex',
'ScanIndexForward' => true
];
$result = DynamoDbFacade::query($iteratorParameters);
I get
{
"__type":"com.amazon.coral.validate#ValidationException",
"message":"Attempted conditional constraint is not an indexable operation"
}
Which is the right way to find the maximum key value ?