O Amazon Redshift não permitirá mais a criação de UDFs do Python a partir do Patch 198. As UDFs do Python existentes continuarão a funcionar normalmente até 30 de junho de 2026. Para ter mais informações, consulte a publicação de blog
Usar DescribeStatement com um SDK da AWS
Os exemplos de código a seguir mostram como usar o DescribeStatement.
Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação em contexto no seguinte exemplo de código:
- .NET
-
- SDK for .NET (v4)
-
nota
Há mais no GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWSCode Examples Repository
. /// <summary> /// Describe a statement execution. /// </summary> /// <param name="statementId">The statement ID.</param> /// <returns>The statement description.</returns> public async Task<DescribeStatementResponse> DescribeStatementAsync(string statementId) { try { var request = new DescribeStatementRequest { Id = statementId }; var response = await _redshiftDataClient.DescribeStatementAsync(request); return response; } catch (Amazon.RedshiftDataAPIService.Model.ResourceNotFoundException ex) { Console.WriteLine($"Statement not found: {ex.Message}"); throw; } catch (Exception ex) { Console.WriteLine($"Couldn't describe statement. Here's why: {ex.Message}"); throw; } }-
Para ver detalhes da API, consulte DescribeStatement em AWS SDK for .NET API Reference.
-
- Java
-
- SDK para Java 2.x
-
nota
Há mais no GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWSCode Examples Repository
. /** * Checks the status of an SQL statement asynchronously and handles the completion of the statement. * * @param sqlId the ID of the SQL statement to check * @return a {@link CompletableFuture} that completes when the SQL statement's status is either "FINISHED" or "FAILED" */ public CompletableFuture<Void> checkStatementAsync(String sqlId) { DescribeStatementRequest statementRequest = DescribeStatementRequest.builder() .id(sqlId) .build(); return getAsyncDataClient().describeStatement(statementRequest) .thenCompose(response -> { String status = response.statusAsString(); logger.info("... Status: {} ", status); if ("FAILED".equals(status)) { throw new RuntimeException("The Query Failed. Ending program"); } else if ("FINISHED".equals(status)) { return CompletableFuture.completedFuture(null); } else { // Sleep for 1 second and recheck status return CompletableFuture.runAsync(() -> { try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { throw new RuntimeException("Error during sleep: " + e.getMessage(), e); } }).thenCompose(ignore -> checkStatementAsync(sqlId)); // Recursively call until status is FINISHED or FAILED } }).whenComplete((result, exception) -> { if (exception != null) { // Handle exceptions logger.info("Error: {} ", exception.getMessage()); } else { logger.info("The statement is finished!"); } }); }-
Para ver detalhes da API, consulte DescribeStatement em AWS SDK for Java 2.x API Reference.
-
- Python
-
- SDK para Python (Boto3).
-
nota
Há mais no GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWSCode Examples Repository
. class RedshiftDataWrapper: """Encapsulates Amazon Redshift data.""" def __init__(self, client): """ :param client: A Boto3 RedshiftDataWrapper client. """ self.client = client def describe_statement(self, statement_id): """ Describes a SQL statement. :param statement_id: The SQL statement identifier. :return: The SQL statement result. """ try: response = self.client.describe_statement(Id=statement_id) return response except ClientError as err: logging.error( "Couldn't describe statement. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raiseO código a seguir instancia o objeto RedshiftDataWrapper.
client = boto3.client("redshift-data") redshift_data_wrapper = RedshiftDataWrapper(client)-
Para ver detalhes da API, consulte DescribeStatement em AWS SDK for Python (Boto3) API Reference.
-
- SAP ABAP
-
- SDK para SAP ABAP
-
nota
Há mais no GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWSCode Examples Repository
. TRY. " Example values: iv_statement_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' oo_result = lo_rsd->describestatement( iv_id = iv_statement_id ). lv_status = oo_result->get_status( ). MESSAGE |Statement status: { lv_status }| TYPE 'I'. CATCH /aws1/cx_rsdresourcenotfoundex. MESSAGE 'Statement not found.' TYPE 'I'. CATCH /aws1/cx_rsdinternalserverex. MESSAGE 'Internal server error.' TYPE 'I'. ENDTRY.-
Para ver detalhes da API, consulte DescribeStatement na Referência de API do SDK da AWS para SAP ABAP.
-
Para ver uma lista completa dos guias de desenvolvedor e exemplos de código do SDK da AWS, consulte Usar este serviço com um AWS SDK. Este tópico também inclui informações sobre como começar e detalhes sobre versões anteriores do SDK.