adriangb commented on code in PR #20061:
URL: https://github.com/apache/datafusion/pull/20061#discussion_r2748074813
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1968,9 +2115,16 @@ fn extract_dml_filters(input: &Arc<LogicalPlan>) ->
Result<Vec<Expr>> {
let mut filters = Vec::new();
input.apply(|node| {
- if let LogicalPlan::Filter(filter) = node {
- // Split AND predicates into individual expressions
-
filters.extend(split_conjunction(&filter.predicate).into_iter().cloned());
+ match node {
+ LogicalPlan::Filter(filter) => {
+ // Split AND predicates into individual expressions
+
filters.extend(split_conjunction(&filter.predicate).into_iter().cloned());
+ }
+ LogicalPlan::TableScan(scan) => {
+ // Also extract filters from TableScan (where they may be
pushed down)
+ filters.extend(scan.filters.iter().cloned());
Review Comment:
> I don't know how the DML stuff is supposed to handle more complex cases
involving `EXISTS`, etc.
E.g.:
```sql
-- 1. Setup: Create tables
CREATE TEMP TABLE departments (
dept_id INT,
dept_name TEXT,
is_active BOOLEAN
);
CREATE TEMP TABLE employees (
emp_id SERIAL PRIMARY KEY,
name TEXT,
dept_name TEXT,
salary INT
);
-- 2. Seed Data
INSERT INTO departments VALUES (1, 'Engineering', true), (2, 'Marketing',
false);
INSERT INTO employees (name, dept_name, salary) VALUES
('Alice', 'Engineering', 5000),
('Bob', 'Engineering', 5000),
('Charlie', 'Marketing', 4000);
-- 3. Execute the UPDATE with a subquery in the WHERE clause
-- Goal: Give a 10% raise only to people in the 'Engineering' department
UPDATE employees
SET salary = salary * 1.10
WHERE dept_name = (
SELECT dept_name
FROM departments
WHERE dept_id = 1
LIMIT 1
);
-- 4. Verify the results
SELECT * FROM employees;
```
This seems to work in postgres.
But again I'm not sure if this is directly something this PR should handle.
--
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]