delete Method
Description
Deletes a NoSQL table or or specific table items.
-
In the current release, to delete a partitioned table you need to delete each table partition separately, by issuing multiple
delete calls and setting thetable parameter in each call to the path to a different partition directory. After deleting all the partitions, you can call thedelete 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]])
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
Parameters
- backend
The backend type —
"nosql"
or"kv"
for the NoSQL backend. See Backend Types.- Type:
str
- Requirement: Required
- Type:
- 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
- Type:
- 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 theis_registered attribute isfalse
or the value of theage attribute is smaller than 18.- Type:
str
- Requirement: Optional
- Default Value:
""
— delete the entire table and its schema file
- Type:
- 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 theframes_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
Examples
Following are some usage examples for the
-
Delete a
mytable table in the client's data container (table ). Because thefilter parameter isn't set, the entire table is deleted.table = "mytable" client.delete(backend="nosql", table=table)
-
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)
-
For a
my_tables/students_11-15 table in the client's data container (table ), delete all items whoseage attribute value is greater than 40 (seefilter ); 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)