By using AWS re:Post, you agree to the AWS re:Post Terms of Use

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

2 minute read
0

I want to increase the maximum string length. But 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;".

Resolution

The maximum query string length in Athena is 262,144 bytes. The maximum string length isn't an adjustable quota, so AWS Support can't increase the maximum string length for you. To get the results that you want from a long query string, split long queries into multiple shorter queries.

To split a long query into multiple shorter queries, use one or more of the following methods:

  • Run multiple DDL statements. For example, when you need to add thousands of partitions to a table, run multiple ALTER TABLE ADD PARTITION queries instead of one long query.
  • Use multiple views. Each view allows a query string length of 262,144 bytes.
  • Use a CREATE TABLE AS SELECT (CTAS) query to break a long query into multiple shorter queries. Then, pass the results of one query to another query.

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

Related information

Service quotas

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago