Interface SupportsDelete
- All Superinterfaces:
SupportsDeleteV2
,Table
,TruncatableTable
Table
delete support. Data sources can implement this
interface to provide the ability to delete data from tables that matches filter expressions.- Since:
- 3.0.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.default boolean
canDeleteWhere
(Filter[] filters) Checks whether it is possible to delete data from a data source table that matches filter expressions.default void
deleteWhere
(Predicate[] predicates) Delete data from a data source table that matches filter expressions.void
deleteWhere
(Filter[] filters) 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(Filter[])
would reject the delete operation because it requires significant effort. If this method returns false, Spark will not calldeleteWhere(Filter[])
and will try to rewrite the delete operation and produce row-level changes if the data source table supports deleting individual records.- Parameters:
filters
- filter expressions, used to select rows to delete when all expressions match- Returns:
- true if the delete operation can be performed
- Since:
- 3.1.0
-
deleteWhere
Delete data from a data source table that matches filter expressions. Note that this method will be invoked only ifcanDeleteWhere(Filter[])
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:
filters
- filter expressions, used to select rows to delete when all expressions match- Throws:
IllegalArgumentException
- If the delete is rejected due to required effort
-
canDeleteWhere
Description copied from interface:SupportsDeleteV2
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
SupportsDeleteV2.deleteWhere(Predicate[])
would reject the delete operation because it requires significant effort. If this method returns false, Spark will not callSupportsDeleteV2.deleteWhere(Predicate[])
and will try to rewrite the delete operation and produce row-level changes if the data source table supports deleting individual records.- Specified by:
canDeleteWhere
in interfaceSupportsDeleteV2
- Parameters:
predicates
- V2 filter expressions, used to select rows to delete when all expressions match- Returns:
- true if the delete operation can be performed
-
deleteWhere
Description copied from interface:SupportsDeleteV2
Delete data from a data source table that matches filter expressions. Note that this method will be invoked only ifSupportsDeleteV2.canDeleteWhere(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.- Specified by:
deleteWhere
in interfaceSupportsDeleteV2
- Parameters:
predicates
- predicate expressions, used to select rows to delete when all expressions match
-
truncateTable
default boolean truncateTable()Description copied from interface:TruncatableTable
Truncate a table by removing all rows from the table atomically.- Specified by:
truncateTable
in interfaceSupportsDeleteV2
- Specified by:
truncateTable
in interfaceTruncatableTable
- Returns:
- true if a table was truncated successfully otherwise false
-