-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I like to support eliminating common subexpressions from a query plan.
For example, this example from TCP-H query 1:
select *
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge
from Tcould be rewritten to reuse the result of l_extendedprice * (1 - l_discount) by moving it into another projection.
This looks in SQL as something like:
with temp as (
select
l_extendedprice * (1 - l_discount) as cs
from t
)
select
sum(cs) as sum_disc_price,
sum(cs * (1 + l_tax)) as sum_charge
from tempDescribe the solution you'd like
Detect common subexpression in projections / group by, join conditions etc. and remove them by moving doing them once in a projection step. Note: this only makes sense when the expression includes any calculation (e.g. not a column reference with alias).
Describe alternatives you've considered
n/a
Additional context
n/a
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request