aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.6k stars 1.55k forks source link

Invalid FilterExpression: The expression contains too many operators; operator count: 301 #3721

Closed abjagtap closed 2 months ago

abjagtap commented 3 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug I am querying on DDB following is my request.

aws:dynamodb:query:request - {
"FilterExpression": "(#a2 >= :v2 AND #a3 <= :v3) AND (#a4 >= :v4) AND (#a5 >= :v5) AND (#a6 <> :v6 AND #a7 <> :v7 AND #a8 <> :v8 AND #a9 <> :v9 AND #a10 <> :v10 AND #a11 <> :v11 AND #a12 <> :v12 AND #a13 <> :v13 AND #a14 <> :v14 AND #a15 <> :v15 AND #a16 <> :v16 AND #a17 <> :v17 AND #a18 <> :v18 AND #a19 <> :v19 AND #a20 <> :v20 AND #a21 <> :v21 AND #a22 <> :v22 AND #a23 <> :v23 AND #a24 <> :v24 AND #a25 <> :v25 AND #a26 <> :v26 AND #a27 <> :v27 AND #a28 <> :v28 AND #a29 <> :v29 AND #a30 <> :v30 AND #a31 <> :v31 AND #a32 <> :v32 AND #a33 <> :v33 AND #a34 <> :v34) AND (#a35 <> :v35 AND #a36 <> :v36 AND #a37 <> :v37 AND #a38 <> :v38 AND #a39 <> :v39 AND #a40 <> :v40 AND #a41 <> :v41 AND #a42 <> :v42 AND #a43 <> :v43 AND #a44 <> :v44 AND #a45 <> :v45 AND #a46 <> :v46 AND #a47 <> :v47 AND #a48 <> :v48 AND #a49 <> :v49 AND #a50 <> :v50 AND #a51 <> :v51 AND #a52 <> :v52 AND #a53 <> :v53 AND #a54 <> :v54 AND #a55 <> :v55 AND #a56 <> :v56 AND #a57 <> :v57 AND #a58 <> :v58 AND #a59 <> :v59 AND #a60 <> :v60 AND #a61 <> :v61 AND #a62 <> :v62 AND #a63 <> :v63) AND (#a64 <> :v64 AND #a65 <> :v65 AND #a66 <> :v66 AND #a67 <> :v67 AND #a68 <> :v68 AND #a69 <> :v69 AND #a70 <> :v70 AND #a71 <> :v71 AND #a72 <> :v72 AND #a73 <> :v73 AND #a74 <> :v74 AND #a75 <> :v75 AND #a76 <> :v76 AND #a77 <> :v77 AND #a78 <> :v78 AND #a79 <> :v79 AND #a80 <> :v80 AND #a81 <> :v81 AND #a82 <> :v82 AND #a83 <> :v83 AND #a84 <> :v84 AND #a85 <> :v85 AND #a86 <> :v86 AND #a87 <> :v87 AND #a88 <> :v88 AND #a89 <> :v89 AND #a90 <> :v90 AND #a91 <> :v91 AND #a92 <> :v92) AND (#a93 <> :v93 AND #a94 <> :v94 AND #a95 <> :v95 AND #a96 <> :v96 AND #a97 <> :v97 AND #a98 <> :v98 AND #a99 <> :v99 AND #a100 <> :v100 AND #a101 <> :v101 AND #a102 <> :v102 AND #a103 <> :v103 AND #a104 <> :v104 AND #a105 <> :v105 AND #a106 <> :v106 AND #a107 <> :v107 AND #a108 <> :v108 AND #a109 <> :v109 AND #a110 <> :v110 AND #a111 <> :v111 AND #a112 <> :v112 AND #a113 <> :v113 AND #a114 <> :v114 AND #a115 <> :v115 AND #a116 <> :v116 AND #a117 <> :v117 AND #a118 <> :v118 AND #a119 <> :v119 AND #a120 <> :v120 AND #a121 <> :v121) AND (#a122 <> :v122 AND #a123 <> :v123 AND #a124 <> :v124 AND #a125 <> :v125 AND #a126 <> :v126 AND #a127 <> :v127 AND #a128 <> :v128 AND #a129 <> :v129 AND #a130 <> :v130 AND #a131 <> :v131 AND #a132 <> :v132 AND #a133 <> :v133 AND #a134 <> :v134 AND #a135 <> :v135 AND #a136 <> :v136 AND #a137 <> :v137 AND #a138 <> :v138 AND #a139 <> :v139 AND #a140 <> :v140 AND #a141 <> :v141 AND #a142 <> :v142 AND #a143 <> :v143 AND #a144 <> :v144 AND #a145 <> :v145 AND #a146 <> :v146 AND #a147 <> :v147 AND #a148 <> :v148 AND #a149 <> :v149 AND #a150 <> :v150) AND (#a151 <> :v151 AND #a152 <> :v152 AND #a153 <> :v153 AND #a154 <> :v154 AND #a155 <> :v155 AND #a156 <> :v156 AND #a157 <> :v157 AND #a158 <> :v158 AND #a159 <> :v159 AND #a160 <> :v160 AND #a161 <> :v161 AND #a162 <> :v162 AND #a163 <> :v163 AND #a164 <> :v164 AND #a165 <> :v165 AND #a166 <> :v166 AND #a167 <> :v167 AND #a168 <> :v168 AND #a169 <> :v169 AND #a170 <> :v170 AND #a171 <> :v171 AND #a172 <> :v172 AND #a173 <> :v173 AND #a174 <> :v174 AND #a175 <> :v175 AND #a176 <> :v176 AND #a177 <> :v177 AND #a178 <> :v178 AND #a179 <> :v179)",
"ExpressionAttributeNames": {

getting error Invalid FilterExpression: The expression contains too many operators; operator count: 301

I am not sure what is an issue I tried in AWS documents but didn't found the relevant link for the above error, do I need to minimize filter expression or is there any workaround?

Thanks in advance.

Is the issue in the browser/Node.js? Browser/Node.js

If on Node.js, are you running this on AWS Lambda?

Details of the browser/Node.js version Paste output of npx envinfo --browsers or node -v

SDK version number Example: v2.466.0

To Reproduce (observed behavior) Steps to reproduce the behavior (please share code or minimal repo)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

ajredniwja commented 3 years ago

Hey @abjagtap thanks for opening this issue, I was not able to find any documentation as well, I have contacted the DynamoDB team internally to check with them. Most probably this will be something that gets added to the documentation.

uvdoctor commented 2 years ago

Is there any update to this bug? I am also facing this issue

shkomg commented 1 year ago

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.

Absolutely ridiculous if you want only results NOT IN that array :(

aBurmeseDev commented 2 months ago

Hi everyone - please understand that this change requires attention from the DynamoDB service team, and we have not seen any progress since notifying them.

Since there are no pending action items for the SDK team, and this repository is solely dedicated to SDK-related issues, I will proceed to close this case. However, please feel free to contact the service team directly through AWS Support for further assistance and updates regarding this change.