ethan-tyler commented on code in PR #19142:
URL: https://github.com/apache/datafusion/pull/19142#discussion_r2633468939
##########
datafusion/catalog/src/memory/table.rs:
##########
@@ -295,4 +304,320 @@ impl TableProvider for MemTable {
fn get_column_default(&self, column: &str) -> Option<&Expr> {
self.column_defaults.get(column)
}
+
+ async fn delete_from(
+ &self,
+ state: &dyn Session,
+ filters: Vec<Expr>,
+ ) -> Result<Arc<dyn ExecutionPlan>> {
+ // Early exit if table has no partitions
+ if self.batches.is_empty() {
+ return Ok(Arc::new(DmlResultExec::new(0)));
+ }
+
+ *self.sort_order.lock() = vec![];
+
+ let mut total_deleted: u64 = 0;
+ let df_schema = DFSchema::try_from(Arc::clone(&self.schema))?;
+
+ for partition_data in &self.batches {
+ let mut partition = partition_data.write().await;
+ let mut new_batches = Vec::with_capacity(partition.len());
+
+ for batch in partition.iter() {
+ if batch.num_rows() == 0 {
+ continue;
+ }
+
+ let filter_mask = if filters.is_empty() {
+ BooleanArray::from(vec![true; batch.num_rows()])
Review Comment:
Good call - now returns None for empty filters instead of allocating an
all-true mask.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]