airflow.providers.amazon.aws.hooks.redshift_data

Module Contents

Classes

RedshiftDataHook

Interact with Amazon Redshift Data API.

class airflow.providers.amazon.aws.hooks.redshift_data.RedshiftDataHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsGenericHook[mypy_boto3_redshift_data.RedshiftDataAPIServiceClient]

Interact with Amazon Redshift Data API. Provide thin wrapper around boto3.client("redshift-data").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

execute_query(database, sql, cluster_identifier=None, db_user=None, parameters=None, secret_arn=None, statement_name=None, with_event=False, wait_for_completion=True, poll_interval=10)[source]

Execute a statement against Amazon Redshift.

Parameters
  • database (str) – the name of the database

  • sql (str | list[str]) – the SQL statement or list of SQL statement to run

  • cluster_identifier (str | None) – unique identifier of a cluster

  • db_user (str | None) – the database username

  • parameters (Iterable | None) – the parameters for the SQL statement

  • secret_arn (str | None) – the name or ARN of the secret that enables db access

  • statement_name (str | None) – the name of the SQL statement

  • with_event (bool) – indicates whether to send an event to EventBridge

  • wait_for_completion (bool) – indicates whether to wait for a result, if True wait, if False don’t wait

  • poll_interval (int) – how often in seconds to check the query status

Returns statement_id

str, the UUID of the statement

Return type

str

wait_for_results(statement_id, poll_interval)[source]
get_table_primary_key(table, database, schema='public', cluster_identifier=None, db_user=None, secret_arn=None, statement_name=None, with_event=False, wait_for_completion=True, poll_interval=10)[source]

Helper method that returns the table primary key.

Copied from RedshiftSQLHook.get_table_primary_key()

Parameters
  • table (str) – Name of the target table

  • database (str) – the name of the database

  • schema (str | None) – Name of the target schema, public by default

  • sql – the SQL statement or list of SQL statement to run

  • cluster_identifier (str | None) – unique identifier of a cluster

  • db_user (str | None) – the database username

  • secret_arn (str | None) – the name or ARN of the secret that enables db access

  • statement_name (str | None) – the name of the SQL statement

  • with_event (bool) – indicates whether to send an event to EventBridge

  • wait_for_completion (bool) – indicates whether to wait for a result, if True wait, if False don’t wait

  • poll_interval (int) – how often in seconds to check the query status

Returns

Primary key columns list

Return type

list[str] | None

Was this entry helpful?