Skip to content

delete_record

delete_record(
    feature_group_name: FeatureGroupNameOrArn,
    *,
    config_overrides: Optional[SageMakerFeatureStoreRuntimeClientConfig] = None,
    record_identifier_value_as_string: Optional[ValueAsString] = None,
    event_time: Optional[ValueAsString] = None,
    target_stores: Optional[TargetStores] = None,
    deletion_mode: Optional[DeletionMode] = None,
) -> None

Deletes a Record from a FeatureGroup in the OnlineStore. Feature Store supports both SoftDelete and HardDelete. For SoftDelete (default), feature columns are set to null and the record is no longer retrievable by GetRecord or BatchGetRecord. For HardDelete, the complete Record is removed from the OnlineStore. In both cases, Feature Store appends the deleted record marker to the OfflineStore. The deleted record marker is a record with the same RecordIdentifer as the original, but with is_deleted value set to True, EventTime set to the delete input EventTime, and other feature values set to null.

Note that the EventTime specified in DeleteRecord should be set later than the EventTime of the existing record in the OnlineStore for that RecordIdentifer. If it is not, the deletion does not occur:

  • For SoftDelete, the existing (not deleted) record remains in the OnlineStore, though the delete record marker is still written to the OfflineStore.

  • HardDelete returns EventTime: 400 ValidationException to indicate that the delete operation failed. No delete record marker is written to the OfflineStore.

When a record is deleted from the OnlineStore, the deleted record marker is appended to the OfflineStore. If you have the Iceberg table format enabled for your OfflineStore, you can remove all history of a record from the OfflineStore using Amazon Athena or Apache Spark. For information on how to hard delete a record from the OfflineStore with the Iceberg table format enabled, see Delete records from the offline store.

Parameters:

  • feature_group_name (FeatureGroupNameOrArn) –

    The name or Amazon Resource Name (ARN) of the feature group to delete the record from.

  • record_identifier_value_as_string (Optional[ValueAsString], default: None ) –

    The value for the RecordIdentifier that uniquely identifies the record, in string format.

  • event_time (Optional[ValueAsString], default: None ) –

    Timestamp indicating when the deletion event occurred. EventTime can be used to query data at a certain point in time.

  • target_stores (Optional[TargetStores], default: None ) –

    A list of stores from which you're deleting the record. By default, Feature Store deletes the record from all of the stores that you're using for the FeatureGroup.

  • deletion_mode (Optional[DeletionMode], default: None ) –

    The name of the deletion mode for deleting the record. By default, the deletion mode is set to SoftDelete.

Raises:

  • AccessForbidden –

    You do not have permission to perform an action.

  • InternalFailure –

    An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.

  • ServiceUnavailable –

    The service is currently unavailable.

  • ValidationError –

    There was an error validating your request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sagemaker_featurestore_runtime/_services/sage_maker_feature_store_runtime.py
def delete_record(
    self,
    feature_group_name: "capo_sagemaker_featurestore_runtime.types.feature_group_name_or_arn.FeatureGroupNameOrArn",
    *,
    config_overrides: Optional[SageMakerFeatureStoreRuntimeClientConfig] = None,
    record_identifier_value_as_string: Optional[
        "capo_sagemaker_featurestore_runtime.types.value_as_string.ValueAsString"
    ] = None,
    event_time: Optional[
        "capo_sagemaker_featurestore_runtime.types.value_as_string.ValueAsString"
    ] = None,
    target_stores: Optional[
        "capo_sagemaker_featurestore_runtime.types.target_stores.TargetStores"
    ] = None,
    deletion_mode: Optional[
        "capo_sagemaker_featurestore_runtime.types.deletion_mode.DeletionMode"
    ] = None,
) -> None:
    """<p>Deletes a <code>Record</code> from a <code>FeatureGroup</code> in the <code>OnlineStore</code>. Feature Store supports both <code>SoftDelete</code> and <code>HardDelete</code>. For <code>SoftDelete</code> (default), feature columns are set to <code>null</code> and the record is no longer retrievable by <code>GetRecord</code> or <code>BatchGetRecord</code>. For <code>HardDelete</code>, the complete <code>Record</code> is removed from the <code>OnlineStore</code>. In both cases, Feature Store appends the deleted record marker to the <code>OfflineStore</code>. The deleted record marker is a record with the same <code>RecordIdentifer</code> as the original, but with <code>is_deleted</code> value set to <code>True</code>, <code>EventTime</code> set to the delete input <code>EventTime</code>, and other feature values set to <code>null</code>.</p> <p>Note that the <code>EventTime</code> specified in <code>DeleteRecord</code> should be set later than the <code>EventTime</code> of the existing record in the <code>OnlineStore</code> for that <code>RecordIdentifer</code>. If it is not, the deletion does not occur:</p> <ul> <li> <p>For <code>SoftDelete</code>, the existing (not deleted) record remains in the <code>OnlineStore</code>, though the delete record marker is still written to the <code>OfflineStore</code>.</p> </li> <li> <p> <code>HardDelete</code> returns <code>EventTime</code>: <code>400 ValidationException</code> to indicate that the delete operation failed. No delete record marker is written to the <code>OfflineStore</code>.</p> </li> </ul> <p>When a record is deleted from the <code>OnlineStore</code>, the deleted record marker is appended to the <code>OfflineStore</code>. If you have the Iceberg table format enabled for your <code>OfflineStore</code>, you can remove all history of a record from the <code>OfflineStore</code> using Amazon Athena or Apache Spark. For information on how to hard delete a record from the <code>OfflineStore</code> with the Iceberg table format enabled, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/feature-store-delete-records.html#feature-store-delete-records-offline-store">Delete records from the offline store</a>.</p>

    Args:
        feature_group_name: <p>The name or Amazon Resource Name (ARN) of the feature group to delete the record from. </p>
        record_identifier_value_as_string: <p>The value for the <code>RecordIdentifier</code> that uniquely identifies the record, in string format. </p>
        event_time: <p>Timestamp indicating when the deletion event occurred. <code>EventTime</code> can be used to query data at a certain point in time.</p>
        target_stores: <p>A list of stores from which you're deleting the record. By default, Feature Store deletes the record from all of the stores that you're using for the <code>FeatureGroup</code>.</p>
        deletion_mode: <p>The name of the deletion mode for deleting the record. By default, the deletion mode is set to <code>SoftDelete</code>.</p>

    Raises:
        capo_sagemaker_featurestore_runtime.errors.access_forbidden.AccessForbidden: <p>You do not have permission to perform an action.</p>
        capo_sagemaker_featurestore_runtime.errors.internal_failure.InternalFailure: <p>An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.</p>
        capo_sagemaker_featurestore_runtime.errors.service_unavailable.ServiceUnavailable: <p>The service is currently unavailable.</p>
        capo_sagemaker_featurestore_runtime.errors.validation_error.ValidationError: <p>There was an error validating your request.</p>
        capo_sagemaker_featurestore_runtime.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker_featurestore_runtime.types.delete_record_request.DeleteRecordRequest]",
    ) -> OperationResponse[None]:
        import capo_sagemaker_featurestore_runtime._operations.amazon_sage_maker_feature_store_runtime.delete_record

        output, http_response = (
            capo_sagemaker_featurestore_runtime._operations.amazon_sage_maker_feature_store_runtime.delete_record.delete_record(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteRecord")
    )
    input_: capo_sagemaker_featurestore_runtime.types.delete_record_request.DeleteRecordRequest = {
        "feature_group_name": feature_group_name
    }
    if record_identifier_value_as_string is not None:
        input_["record_identifier_value_as_string"] = (
            record_identifier_value_as_string
        )
    if event_time is not None:
        input_["event_time"] = event_time
    if target_stores is not None:
        input_["target_stores"] = target_stores
    if deletion_mode is not None:
        input_["deletion_mode"] = deletion_mode

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