View a markdown version of this page

Descrivere i metadati relativi a un’istruzione SQL - Amazon Redshift

Amazon Redshift non supporterà più l'uso delle UDF Python dopo il 30 giugno 2026. Inizieremo ad applicarlo per fasi. Per ulteriori informazioni sulla fine del ciclo di vita e sulle opzioni di migrazione di Python, consulta il post del blog pubblicato il 30 giugno 2025.

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Descrivere i metadati relativi a un’istruzione SQL

Per ottenere descrizioni dei metadati per un'istruzione SQL, usa il comando. aws redshift-data describe-statement AWS CLI È inoltre possibile utilizzare questo comando per descrivere singole sottodichiarazioni all'interno di un batch fornendo l'ID della sottodichiarazione. L'autorizzazione per eseguire questo comando si basa sulle autorizzazioni IAM del chiamante.

Facoltativamente, per ridurre il numero di richieste di sondaggio, utilizzate il WaitTimeSeconds parametro per concedere più tempo per l'aggiornamento dello stato di un'operazione nell'ambito di questa chiamata API. Per ulteriori informazioni, consulta Riduci le chiamate API con un polling lungo.

Il AWS CLI comando seguente descrive un'istruzione SQL.

aws redshift-data describe-statement --id d9b6c0c9-0747-4bf4-b142-e8883122f766

Di seguito è riportato un esempio della risposta.

{ "ClusterIdentifier": "mycluster-test", "CreatedAt": 1598306924.632, "Duration": 1095981511, "Id": "d9b6c0c9-0747-4bf4-b142-e8883122f766", "QueryString": "select * from stl_query limit 1", "RedshiftPid": 20859, "RedshiftQueryId": 48879, "ResultRows": 1, "ResultSize": 4489, "Status": "FINISHED", "UpdatedAt": 1598306926.667 }

Di seguito è riportato un esempio di una risposta describe-statement dopo aver eseguito un comando batch-execute-statement con più istruzioni SQL.

{ "ClusterIdentifier": "mayo", "CreatedAt": 1623979777.126, "Duration": 6591877, "HasResultSet": true, "Id": "b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652", "RedshiftPid": 31459, "RedshiftQueryId": 0, "ResultRows": 2, "ResultSize": 22, "Status": "FINISHED", "SubStatements": [ { "CreatedAt": 1623979777.274, "Duration": 3396637, "HasResultSet": true, "Id": "b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652:1", "QueryString": "select 1;", "RedshiftQueryId": -1, "ResultRows": 1, "ResultSize": 11, "Status": "FINISHED", "UpdatedAt": 1623979777.903 }, { "CreatedAt": 1623979777.274, "Duration": 3195240, "HasResultSet": true, "Id": "b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652:2", "QueryString": "select 2;", "RedshiftQueryId": -1, "ResultRows": 1, "ResultSize": 11, "Status": "FINISHED", "UpdatedAt": 1623979778.076 } ], "UpdatedAt": 1623979778.183 }

Il AWS CLI comando seguente descrive una sottodichiarazione specifica all'interno di un batch fornendo l'ID della sottodichiarazione.

aws redshift-data describe-statement --id b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652:2

Di seguito è riportato un esempio della risposta. Lo stato dell'istruzione principale è STARTED dovuto al fatto che il batch non è ancora stato completato. L'SubStatementsarray contiene solo la sottodichiarazione richiesta.

{ "ClusterIdentifier": "mayo", "CreatedAt": 1623979777.126, "Duration": 0, "HasResultSet": false, "Id": "b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652", "RedshiftPid": 31459, "RedshiftQueryId": 0, "Status": "STARTED", "SubStatements": [ { "CreatedAt": 1623979777.274, "Duration": 3195240, "HasResultSet": true, "Id": "b2906c76-fa6e-4cdf-8c5f-4de1ff9b7652:2", "QueryString": "select 2;", "RedshiftQueryId": -1, "ResultRows": 1, "ResultSize": 11, "Status": "FINISHED", "UpdatedAt": 1623979778.076 } ], "UpdatedAt": 1623979777.503 }