[jira] [Updated] (SPARK-32761) Planner error when aggregating multiple distinct Constant columns

2020-10-15 Thread Wenchen Fan (Jira)


 [ 
https://issues.apache.org/jira/browse/SPARK-32761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Wenchen Fan updated SPARK-32761:

Fix Version/s: 3.0.2

> Planner error when aggregating multiple distinct Constant columns
> -
>
> Key: SPARK-32761
> URL: https://issues.apache.org/jira/browse/SPARK-32761
> Project: Spark
>  Issue Type: Bug
>  Components: SQL
>Affects Versions: 3.0.0
>Reporter: Linhong Liu
>Assignee: Liu, Linhong
>Priority: Major
> Fix For: 3.0.2, 3.1.0
>
>
> SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 2, 3) will trigger this bug.
> The problematic code is:
>  
> {code:java}
> val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e =>
>   val unfoldableChildren = 
> e.aggregateFunction.children.filter(!_.foldable).toSet
>   if (unfoldableChildren.nonEmpty) {
> // Only expand the unfoldable children
>  unfoldableChildren
>   } else {
> // If aggregateFunction's children are all foldable
> // we must expand at least one of the children (here we take the first 
> child),
> // or If we don't, we will get the wrong result, for example:
> // count(distinct 1) will be explained to count(1) after the rewrite 
> function.
> // Generally, the distinct aggregateFunction should not run
> // foldable TypeCheck for the first child.
> e.aggregateFunction.children.take(1).toSet
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org



[jira] [Updated] (SPARK-32761) Planner error when aggregating multiple distinct Constant columns

2020-08-31 Thread Linhong Liu (Jira)


 [ 
https://issues.apache.org/jira/browse/SPARK-32761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Linhong Liu updated SPARK-32761:

Description: 
SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 2, 3) will trigger this bug.

The problematic code is:

 
{code:java}
val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e =>
  val unfoldableChildren = 
e.aggregateFunction.children.filter(!_.foldable).toSet
  if (unfoldableChildren.nonEmpty) {
// Only expand the unfoldable children
 unfoldableChildren
  } else {
// If aggregateFunction's children are all foldable
// we must expand at least one of the children (here we take the first 
child),
// or If we don't, we will get the wrong result, for example:
// count(distinct 1) will be explained to count(1) after the rewrite 
function.
// Generally, the distinct aggregateFunction should not run
// foldable TypeCheck for the first child.
e.aggregateFunction.children.take(1).toSet
  }
}
{code}

  was:
SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 3) will trigger this bug.

The problematic code is:

 
{code:java}
val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e =>
  val unfoldableChildren = 
e.aggregateFunction.children.filter(!_.foldable).toSet
  if (unfoldableChildren.nonEmpty) {
// Only expand the unfoldable children
 unfoldableChildren
  } else {
// If aggregateFunction's children are all foldable
// we must expand at least one of the children (here we take the first 
child),
// or If we don't, we will get the wrong result, for example:
// count(distinct 1) will be explained to count(1) after the rewrite 
function.
// Generally, the distinct aggregateFunction should not run
// foldable TypeCheck for the first child.
e.aggregateFunction.children.take(1).toSet
  }
}
{code}


> Planner error when aggregating multiple distinct Constant columns
> -
>
> Key: SPARK-32761
> URL: https://issues.apache.org/jira/browse/SPARK-32761
> Project: Spark
>  Issue Type: Bug
>  Components: SQL
>Affects Versions: 3.0.0
>Reporter: Linhong Liu
>Priority: Major
>
> SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 2, 3) will trigger this bug.
> The problematic code is:
>  
> {code:java}
> val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e =>
>   val unfoldableChildren = 
> e.aggregateFunction.children.filter(!_.foldable).toSet
>   if (unfoldableChildren.nonEmpty) {
> // Only expand the unfoldable children
>  unfoldableChildren
>   } else {
> // If aggregateFunction's children are all foldable
> // we must expand at least one of the children (here we take the first 
> child),
> // or If we don't, we will get the wrong result, for example:
> // count(distinct 1) will be explained to count(1) after the rewrite 
> function.
> // Generally, the distinct aggregateFunction should not run
> // foldable TypeCheck for the first child.
> e.aggregateFunction.children.take(1).toSet
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org