Files
doris/fe
Chengpeng Yan dee9c2240f [feature](Nereids) pushdown filter through window (#18784)
Support the operator `PartitionTopN`, which can partition first and do the topn operation later in each partition. It used in the following case
```
-- Support push the filter down to the window and generate the PartitionTopN.
-- The plan change from `window -> filter` to `partitionTopN -> window -> filter`.
explain select *  from (select * , row_number() over(partition by b order by a) as num from t ) tt where  num <= 10;

-- Support push the limit down to the window and generate the PartitionTopN. 
-- The plan change from `window -> limit` to `partitionTopN -> window -> limit `.
explain select row_number() over(partition by b order by a) as num from t limit 10;

-- Support push the topn down to the window and generate the PartitionTopN. 
-- The plan change from `window -> topn` to `partitionTopN -> window -> topn `.
explain select row_number() over(partition by b order by a) as num from t order by num limit 10;
```

The FE part detail design:
1. Add the following rewrite rules:
    - PUSHDOWN_FILTER_THROUGH_WINDOW
    - PUSH_LIMIT_THROUGH_PROJECT_WINDOW
    - PUSH_LIMIT_THROUGH_WINDOW
    - PUSHDOWN_TOP_N_THROUGH_PROJECTION_WINDOW
    - PUSHDOWN_TOP_N_THROUGH_WINDOW
2. Add the PartitionTopN node(LogicalPlan/ PhysicalPlan/ TranslatorPlan)
3. For the rewrite plan, there are several requests that need to meet:
    - For the `Filter` part, only consider `</ <=/ =` conditions. And the filter conditions will be stored.
    - For the `Window` part, we only support one window function. And we support the `row_number`, `rank`, `dense_rank` window functions. And the `partition by` key and `order by` key can not be empty at the same time. The `Window Frame` should be `UNBOUNDED to CURRENT`.
4. For the `PhysicalPartitionTopN`, the requested property is `Any`and the output property is its children's property.

That's the main details that are very important. For the other part, you can directly check the code.

Issue Number #18646

BE Part #19708
2023-05-26 11:23:48 +08:00
..

# 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.

# fe-common

This module is used to store some common classes of other modules.

# spark-dpp

This module is Spark DPP program, used for Spark Load function.
Depends: fe-common

# fe-core

This module is the main process module of FE.
Depends: fe-common, spark-dpp