Support to query rewrite by materialized view when join input has aggregate, the aggregate should be simple For example as following: The materialized view def is > select > l_linenumber, > count(distinct l_orderkey), > sum(case when l_orderkey in (1,2,3) then l_suppkey * l_linenumber else 0 end), > max(case when l_orderkey in (4, 5) then (l_quantity *2 + part_supp_a.qty_max) * 0.88 else 100 end), > avg(case when l_partkey in (2, 3, 4) then l_discount + o_totalprice + part_supp_a.qty_sum else 50 end) > from lineitem > left join orders on l_orderkey = o_orderkey > left join > (select ps_partkey, ps_suppkey, sum(ps_availqty) qty_sum, max(ps_availqty) qty_max, > min(ps_availqty) qty_min, > avg(ps_supplycost) cost_avg > from partsupp > group by ps_partkey,ps_suppkey) part_supp_a > on l_partkey = part_supp_a.ps_partkey > and l_suppkey = part_supp_a.ps_suppkey > group by l_linenumber; when query is like following, it can be rewritten by mv above > select > l_linenumber, > sum(case when l_orderkey in (1,2,3) then l_suppkey * l_linenumber else 0 end), > avg(case when l_partkey in (2, 3, 4) then l_discount + o_totalprice + part_supp_a.qty_sum else 50 end) > from lineitem > left join orders on l_orderkey = o_orderkey > left join > (select ps_partkey, ps_suppkey, sum(ps_availqty) qty_sum, max(ps_availqty) qty_max, > min(ps_availqty) qty_min, > avg(ps_supplycost) cost_avg > from partsupp > group by ps_partkey,ps_suppkey) part_supp_a > on l_partkey = part_supp_a.ps_partkey > and l_suppkey = part_supp_a.ps_suppkey > group by l_linenumber;
# 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