How to paginate Redshift Data API statement results using Boto3?

0

Hi,

I'm trying to use the the pagination functionality of the Redshift Data API (using boto3): https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift-data/paginator/GetStatementResult.html

However, I cannot seem to get this to work - I'm expecting a 'NextToken' to be returned in the response, but I never receive this.

I have example code that runs a SQL query to return 2000 rows, and then I'm limiting the RS Data API to return just one row per page (for testing purposes).

You can see from my screenshots below that despite the response stating there are 2000 total rows, it never provides a 'NextToken' to get the next page of resultss

Am I doing something wrong, or is this likely a bug?

Enter image description here

Enter image description here

cgddrd
질문됨 2달 전429회 조회
2개 답변
0

Hi good morning,

Thanks for sending your questions regarding pagination and Redshift Data API using boto3. The boto3 for Redshift Data API supports the following methods: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift-data.html

The method get_paginator () can be used to paginate the results and specifically to the pagination of the method get_statement_result, you can set only MaxItems per page in the configuration (PageSize is not supported).

I've reproduced the scenario using Redshift sample data available in database sample_data_dev and I'm getting the same scenario when using MaxItems.

To help you with some alternatives you can do the following:

Regarding the method get_paginator and the iterator using the paginator for Redshift Data API, I will analyze and revert back as soon as I have more info. Meanwhile, I hope the alternatives I've provided helps to achieve the goals of your development.

AWS
답변함 2달 전
profile picture
전문가
검토됨 2달 전
  • Thanks for your help. Are you able to confirm the conditions under which Redshift will automatically paginate results?

0

Hi good morning,

Regarding the method get_statement_result (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift-data/client/get_statement_result.html)), the Redshift Data API will automatically split the results and return a NextToken automatically based on system internal conditions (query result size, etc). In this API, you can't configure a limit of rows per page (e.g. MaxItems or PageSize). However, as mentioned, the system will split the result automatically based on internal conditions.

AWS
답변함 2달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠