delete Method

On This Page

Description

Deletes a NoSQL table or or specific table items.

Note
  • In the current release, to delete a partitioned table you need to delete each table partition separately, by issuing multiple delete calls and setting the table parameter in each call to the path to a different partition directory. After deleting all the partitions, you can call the delete method with the root table path to delete the table’s schema file and complete the deletion.

  • When the filter parameter isn’t set, the entire table and its schema file (.#schema) are deleted.

Syntax

delete(backend, table[, filter='', if_missing=FAIL]])
Note

The method has additional parameters that aren’t currently supported for the NoSQL backend. Therefore, when calling the method, be sure to explicitly specify the names of all parameters after table.

Parameters

backend | filter | if_missing | table

backend

The backend type — "nosql" or "kv" for the NoSQL backend. See Backend Types.

  • Type: str
  • Requirement: Required
table

The relative path to the backend data — a directory in the target data container (as configured for the client object) that represents a NoSQL table. For example, "mytable" or "examples/nosql/my_table". You can also set the path to a table partition; see the partitioned-table deletion note regarding the need to delete the table partitions before attempting to delete the entire table.

  • Type: str
  • Requirement: Required
filter

A Boolean filter expression that identifies specific items to delete. See Filter Expression for syntax details and examples.
To reference an item attribute in the target table from within the expression, use the attribute name — <attribute name>. For example, an "is_registered==false OR age<18" filter deletes all table items for which either the value of the is_registered attribute is false or the value of the age attribute is smaller than 18.

  • Type: str
  • Requirement: Optional
  • Default Value: "" — delete the entire table and its schema file
if_missing

Determines whether to raise an error when the specified table (table) doesn’t exist.

  • Type:

    pb.ErrorOptions enumeration. To use the enumeration, import the frames_pb2 module; for example:

    from v3io_frames import frames_pb2 as fpb
    
  • Requirement: Optional
  • Valid Values: FAIL to raise an error when the specified table doesn’t exist; IGNORE to ignore this
  • Default Value: FAIL

Errors

In case of an error, the method raises a DeleteError error.

Examples

Following are some usage examples for the delete method of the Frames NoSQL backend:

  1. Delete a mytable table in the client’s data container (table). Because the filter parameter isn’t set, the entire table is deleted.

    table = "mytable"
    client.delete(backend="nosql", table=table)
    
  2. Delete a my_tables/students_11-15 table in the client’s data container (table); don’t raise an error if the table doesn’t exist (if_missing = IGNORE):

    from v3io_frames import frames_pb2 as fpb
    table = "/my_tables/students_11-15"
    client.delete("nosql", table=table, if_missing=fpb.IGNORE)
    
  3. For a my_tables/students_11-15 table in the client’s data container (table), delete all items whose age attribute value is greater than 40 (see filter); don’t raise an error if the table doesn’t exist (if_missing = IGNORE):

    from v3io_frames import frames_pb2 as fpb
    table = "/my_tables/students_11-15"
    client.delete("nosql", table=table, filter="age>40", if_missing=fpb.IGNORE)
    

See Also