Interface SupportsDeleteV2
- All Superinterfaces:
Table
,TruncatableTable
- All Known Subinterfaces:
SupportsDelete
Table
delete support. Data sources can implement this
interface to provide the ability to delete data from tables that matches filter expressions.- Since:
- 3.4.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
canDeleteWhere
(Predicate[] predicates) Checks whether it is possible to delete data from a data source table that matches filter expressions.void
deleteWhere
(Predicate[] predicates) Delete data from a data source table that matches filter expressions.default boolean
Truncate a table by removing all rows from the table atomically.Methods inherited from interface org.apache.spark.sql.connector.catalog.Table
capabilities, columns, name, partitioning, properties, schema
-
Method Details
-
canDeleteWhere
Checks whether it is possible to delete data from a data source table that matches filter expressions.Rows should be deleted from the data source iff all of the filter expressions match. That is, the expressions must be interpreted as a set of filters that are ANDed together.
Spark will call this method at planning time to check whether
deleteWhere(Predicate[])
would reject the delete operation because it requires significant effort. If this method returns false, Spark will not calldeleteWhere(Predicate[])
and will try to rewrite the delete operation and produce row-level changes if the data source table supports deleting individual records.- Parameters:
predicates
- V2 filter expressions, used to select rows to delete when all expressions match- Returns:
- true if the delete operation can be performed
- Since:
- 3.4.0
-
deleteWhere
Delete data from a data source table that matches filter expressions. Note that this method will be invoked only ifcanDeleteWhere(Predicate[])
returns true.Rows are deleted from the data source iff all of the filter expressions match. That is, the expressions must be interpreted as a set of filters that are ANDed together.
Implementations may reject a delete operation if the delete isn't possible without significant effort. For example, partitioned data sources may reject deletes that do not filter by partition columns because the filter may require rewriting files without deleted records. To reject a delete implementations should throw
IllegalArgumentException
with a clear error message that identifies which expression was rejected.- Parameters:
predicates
- predicate expressions, used to select rows to delete when all expressions match- Throws:
IllegalArgumentException
- If the delete is rejected due to required effort
-
truncateTable
default boolean truncateTable()Description copied from interface:TruncatableTable
Truncate a table by removing all rows from the table atomically.- Specified by:
truncateTable
in interfaceTruncatableTable
- Returns:
- true if a table was truncated successfully otherwise false
-