alex-plekhanov commented on a change in pull request #9009: URL: https://github.com/apache/ignite/pull/9009#discussion_r616411130
########## File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/MinusNode.java ########## @@ -0,0 +1,341 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query.calcite.exec.rel; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; +import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler; +import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler.RowFactory; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.GroupKey; +import org.apache.ignite.internal.util.typedef.F; + +/** + * Execution node for MINUS (EXCEPT) operator. + */ +public class MinusNode<Row> extends AbstractNode<Row> { Review comment: > My understanding is matches the Postgres definition Yes, the current implementation matches the Postgres definition too. I got the idea with this optimization, I will implement it. But as I said before, is not always possible, for example, we still need to process all sources on the MAP phase. > On the other hand a query like `SELECT f1 FROM t1 EXCEPT SELECT f1 FROM t2` could be simply rewritten to `SELECT DISTINCT f1 FROM t1 ANTI JOIN t2 USING (f1)` I'm not sure it's more optimal than the current approach. As far as I understand there are some limitations where this approach is applicable: tables `t1` and `t2` should be colocated, there should be an index on `t2` for `f1` columns, `t1` should be sorted by `f1` or streaming mode will be not possible with DISTINCT, etc. I propose to start with the current implementation (as working for all cases and optimal for most cases) and make optimization with anti-join later if we really need it. -- 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. For queries about this service, please contact Infrastructure at: [email protected]
