diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java index a1a6016231c1..03780bbed88f 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java @@ -272,7 +272,7 @@ private WriterTarget createWriterTarget(WriterTarget target, PlanNode planNode) private static List findSourceTableHandles(PlanNode startNode) { return PlanNodeSearcher.searchFrom(startNode) - .where(TableScanNode.class::isInstance) + .where(node -> node instanceof TableScanNode tableScanNode && !tableScanNode.isUpdateTarget()) .findAll() .stream() .map(TableScanNode.class::cast)