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
preguntada hace 2 meses429 visualizaciones
2 Respuestas
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
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses
  • 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
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas