How can I increase the maximum query string length in Amazon Athena?

2 minute read
0

When I run an Amazon Athena query with a long string, I get an error similar to the following: "'queryString' failed to satisfy constraint: Member must have length less than or equal to 262144 (Service: AmazonAthena; Status Code: 400; Error Code: InvalidRequestException;". I want to increase the maximum string length.

Resolution

Maximum query string length (262,144 bytes) is not an adjustable quota. This means that AWS Support can't increase the quota for you. Instead, split long queries into multiple, smaller queries. Here are some examples of how you can do that:

  • Run multiple DDL statements. For example, assume that you're running an ALTER TABLE ADD PARTITION statement to add thousands of partitions to a table. If the query string is greater than 262,144 bytes, run multiple ALTER TABLE ADD PARTITION statements instead of one long one.
  • Use views. Each view allows a query string length of 262,144 bytes.
  • Use CREATE TABLE AS SELECT (CTAS) to break a long query into multiple queries and pass the results of one query to another query.

You can also shorten table, column, and database names to decrease string length.

Related information

Service quotas

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago