You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case when a query involves scalar subquery with mathematical function and the subquery returns no rows, the entire query returns no rows. This only happens in cases with mathematical functions present in the subquery.
Your Environment
Presto version used: 0.290-SNAPSHOT (latest master)
The scalar subquery should return null and other selected columns should return proper values.
Current Behavior
When the scalar subquery returns no rows, the entire query returns 0 rows.
Possible Solution
The query plan in such cases is introducing an empty Values Node in case simplify_plan_with_empty_input is set to true (It is true by default). If it is false, PickTableLayoutForPredicate rule removes TableScan node for the columns not in the subquery. Also an additional FilterNode with false predicate gets introduced.
Steps to Reproduce
Run the below simple query -
select
comment,
(
select
name
from
tpch.tiny.nation
where
nationkey = 1
and regionkey = 1
and width_bucket(nationkey, 1, 100, 10) = 2
)
from
tpch.tiny.nation;
Screenshots (if appropriate)
Outputs
When simplify_plan_with_empty_input is true
When simplify_plan_with_empty_input is false
Context
The text was updated successfully, but these errors were encountered:
In case when a query involves scalar subquery with mathematical function and the subquery returns no rows, the entire query returns no rows. This only happens in cases with mathematical functions present in the subquery.
Your Environment
Expected Behavior
The scalar subquery should return null and other selected columns should return proper values.
Current Behavior
When the scalar subquery returns no rows, the entire query returns 0 rows.
Possible Solution
The query plan in such cases is introducing an empty Values Node in case
simplify_plan_with_empty_input
is set to true (It is true by default). If it is false, PickTableLayoutForPredicate rule removes TableScan node for the columns not in the subquery. Also an additional FilterNode with false predicate gets introduced.Steps to Reproduce
Run the below simple query -
Screenshots (if appropriate)
Outputs
When
simplify_plan_with_empty_input
is trueWhen
simplify_plan_with_empty_input
is falseContext
The text was updated successfully, but these errors were encountered: