Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The IN operator is provided with too many operands; number of operands: 119 dynamodb

Try to use IN operation in dynamodb but get following error. Could anyone help me with alternative solution ?

var params = {

TableName : "table_name",
FilterExpression : "id IN ("+Object.keys(profileIdObject).toString()+ ")",
ExpressionAttributeValues : profileIdObject

};

ERROR :: {

  "message": "Invalid FilterExpression: The IN operator is provided with too many operands; number of operands: 119",
  "code": "ValidationException",
  "time": "2018-02-13T08:48:02.597Z",
  "statusCode": 400,
  "retryable": false,
  "retryDelay": 25.08276239472692

}

like image 741
anil tako Avatar asked Feb 13 '18 09:02

anil tako


1 Answers

According to docs:

The maximum number of operands for the IN comparator is 100

Found here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-expression-parameters

You will need to perform the query/scan in multiple batches, in your case with 100 of Object.keys(profileIdObject).toString() in the first batch and 19 in the second batch. Then coalesce the results.

like image 142
Abram Simon Avatar answered Sep 22 '22 14:09

Abram Simon