Skip to content

restore_table_from_cluster_snapshot

restore_table_from_cluster_snapshot(
    *,
    config_overrides: Optional[RedshiftClientConfig] = None,
    cluster_identifier: Optional[String] = None,
    snapshot_identifier: Optional[String] = None,
    source_database_name: Optional[String] = None,
    source_schema_name: Optional[String] = None,
    source_table_name: Optional[String] = None,
    target_database_name: Optional[String] = None,
    target_schema_name: Optional[String] = None,
    new_table_name: Optional[String] = None,
    enable_case_sensitive_identifier: Optional[BooleanOptional] = None,
) -> RestoreTableFromClusterSnapshotResult

Creates a new table from a table in an Amazon Redshift cluster snapshot. You must create the new table within the Amazon Redshift cluster that the snapshot was taken from.

You cannot use RestoreTableFromClusterSnapshot to restore a table with the same name as an existing table in an Amazon Redshift cluster. That is, you cannot overwrite an existing table in a cluster with a restored table. If you want to replace your original table with a new, restored table, then rename or drop your original table before you call RestoreTableFromClusterSnapshot. When you have renamed your original table, then you can pass the original name of the table as the NewTableName parameter value in the call to RestoreTableFromClusterSnapshot. This way, you can replace the original table with the table created from the snapshot.

You can't use this operation to restore tables with interleaved sort keys.

Parameters:

  • cluster_identifier (Optional[String], default: None ) –

    The identifier of the Amazon Redshift cluster to restore the table to.

  • snapshot_identifier (Optional[String], default: None ) –

    The identifier of the snapshot to restore the table from. This snapshot must have been created from the Amazon Redshift cluster specified by the ClusterIdentifier parameter.

  • source_database_name (Optional[String], default: None ) –

    The name of the source database that contains the table to restore from.

  • source_schema_name (Optional[String], default: None ) –

    The name of the source schema that contains the table to restore from. If you do not specify a SourceSchemaName value, the default is public.

  • source_table_name (Optional[String], default: None ) –

    The name of the source table to restore from.

  • target_database_name (Optional[String], default: None ) –

    The name of the database to restore the table to.

  • target_schema_name (Optional[String], default: None ) –

    The name of the schema to restore the table to.

  • new_table_name (Optional[String], default: None ) –

    The name of the table to create as a result of the current request.

  • enable_case_sensitive_identifier (Optional[BooleanOptional], default: None ) –

    Indicates whether name identifiers for database, schema, and table are case sensitive. If true, the names are case sensitive. If false (default), the names are not case sensitive.

Raises:

Source code in docs_src/capo_redshift/_services/redshift.py
def restore_table_from_cluster_snapshot(
    self,
    *,
    config_overrides: Optional[RedshiftClientConfig] = None,
    cluster_identifier: Optional["capo_redshift.types.string.String"] = None,
    snapshot_identifier: Optional["capo_redshift.types.string.String"] = None,
    source_database_name: Optional["capo_redshift.types.string.String"] = None,
    source_schema_name: Optional["capo_redshift.types.string.String"] = None,
    source_table_name: Optional["capo_redshift.types.string.String"] = None,
    target_database_name: Optional["capo_redshift.types.string.String"] = None,
    target_schema_name: Optional["capo_redshift.types.string.String"] = None,
    new_table_name: Optional["capo_redshift.types.string.String"] = None,
    enable_case_sensitive_identifier: Optional[
        "capo_redshift.types.boolean_optional.BooleanOptional"
    ] = None,
) -> "capo_redshift.types.restore_table_from_cluster_snapshot_result.RestoreTableFromClusterSnapshotResult":
    """<p>Creates a new table from a table in an Amazon Redshift cluster snapshot. You must create the new table within the Amazon Redshift cluster that the snapshot was taken from.</p> <p>You cannot use <code>RestoreTableFromClusterSnapshot</code> to restore a table with the same name as an existing table in an Amazon Redshift cluster. That is, you cannot overwrite an existing table in a cluster with a restored table. If you want to replace your original table with a new, restored table, then rename or drop your original table before you call <code>RestoreTableFromClusterSnapshot</code>. When you have renamed your original table, then you can pass the original name of the table as the <code>NewTableName</code> parameter value in the call to <code>RestoreTableFromClusterSnapshot</code>. This way, you can replace the original table with the table created from the snapshot.</p> <p>You can't use this operation to restore tables with <a href="https://docs.aws.amazon.com/redshift/latest/dg/t_Sorting_data.html#t_Sorting_data-interleaved">interleaved sort keys</a>.</p>

    Args:
        cluster_identifier: <p>The identifier of the Amazon Redshift cluster to restore the table to.</p>
        snapshot_identifier: <p>The identifier of the snapshot to restore the table from. This snapshot must have been created from the Amazon Redshift cluster specified by the <code>ClusterIdentifier</code> parameter.</p>
        source_database_name: <p>The name of the source database that contains the table to restore from.</p>
        source_schema_name: <p>The name of the source schema that contains the table to restore from. If you do not specify a <code>SourceSchemaName</code> value, the default is <code>public</code>.</p>
        source_table_name: <p>The name of the source table to restore from.</p>
        target_database_name: <p>The name of the database to restore the table to.</p>
        target_schema_name: <p>The name of the schema to restore the table to.</p>
        new_table_name: <p>The name of the table to create as a result of the current request.</p>
        enable_case_sensitive_identifier: <p>Indicates whether name identifiers for database, schema, and table are case sensitive. If <code>true</code>, the names are case sensitive. If <code>false</code> (default), the names are not case sensitive.</p>

    Raises:
        capo_redshift.errors.cluster_not_found_fault.ClusterNotFoundFault: <p>The <code>ClusterIdentifier</code> parameter does not refer to an existing cluster. </p>
        capo_redshift.errors.cluster_snapshot_not_found_fault.ClusterSnapshotNotFoundFault: <p>The snapshot identifier does not refer to an existing cluster snapshot.</p>
        capo_redshift.errors.in_progress_table_restore_quota_exceeded_fault.InProgressTableRestoreQuotaExceededFault: <p>You have exceeded the allowed number of table restore requests. Wait for your current table restore requests to complete before making a new request.</p>
        capo_redshift.errors.invalid_cluster_snapshot_state_fault.InvalidClusterSnapshotStateFault: <p>The specified cluster snapshot is not in the <code>available</code> state, or other accounts are authorized to access the snapshot. </p>
        capo_redshift.errors.invalid_cluster_state_fault.InvalidClusterStateFault: <p>The specified cluster is not in the <code>available</code> state. </p>
        capo_redshift.errors.invalid_table_restore_argument_fault.InvalidTableRestoreArgumentFault: <p>The value specified for the <code>sourceDatabaseName</code>, <code>sourceSchemaName</code>, or <code>sourceTableName</code> parameter, or a combination of these, doesn't exist in the snapshot.</p>
        capo_redshift.errors.unsupported_operation_fault.UnsupportedOperationFault: <p>The requested operation isn't supported.</p>
        capo_redshift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_redshift.types.restore_table_from_cluster_snapshot_message.RestoreTableFromClusterSnapshotMessage]",
    ) -> OperationResponse[
        "capo_redshift.types.restore_table_from_cluster_snapshot_result.RestoreTableFromClusterSnapshotResult"
    ]:
        import capo_redshift._operations.redshift_service_version20121201.restore_table_from_cluster_snapshot

        output, http_response = (
            capo_redshift._operations.redshift_service_version20121201.restore_table_from_cluster_snapshot.restore_table_from_cluster_snapshot(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RestoreTableFromClusterSnapshot")
    )
    input_: capo_redshift.types.restore_table_from_cluster_snapshot_message.RestoreTableFromClusterSnapshotMessage = {}
    if cluster_identifier is not None:
        input_["cluster_identifier"] = cluster_identifier
    if snapshot_identifier is not None:
        input_["snapshot_identifier"] = snapshot_identifier
    if source_database_name is not None:
        input_["source_database_name"] = source_database_name
    if source_schema_name is not None:
        input_["source_schema_name"] = source_schema_name
    if source_table_name is not None:
        input_["source_table_name"] = source_table_name
    if target_database_name is not None:
        input_["target_database_name"] = target_database_name
    if target_schema_name is not None:
        input_["target_schema_name"] = target_schema_name
    if new_table_name is not None:
        input_["new_table_name"] = new_table_name
    if enable_case_sensitive_identifier is not None:
        input_["enable_case_sensitive_identifier"] = (
            enable_case_sensitive_identifier
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output