[GitHub] spark pull request #15980: [SPARK-18528][SQL] Fix a bug to initialise an ite...

2016-12-21 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/spark/pull/15980


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15980: [SPARK-18528][SQL] Fix a bug to initialise an ite...

2016-11-23 Thread maropu
Github user maropu commented on a diff in the pull request:

https://github.com/apache/spark/pull/15980#discussion_r89420600
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala ---
@@ -67,23 +67,14 @@ trait BaseLimitExec extends UnaryExecNode with 
CodegenSupport {
   }
 
   override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: 
ExprCode): String = {
-val stopEarly = ctx.freshName("stopEarly")
-ctx.addMutableState("boolean", stopEarly, s"$stopEarly = false;")
-
-ctx.addNewFunction("shouldStop", s"""
-  @Override
-  protected boolean shouldStop() {
-return !currentRows.isEmpty() || $stopEarly;
-  }
-""")
 val countTerm = ctx.freshName("count")
 ctx.addMutableState("int", countTerm, s"$countTerm = 0;")
 s"""
| if ($countTerm < $limit) {
|   $countTerm += 1;
|   ${consume(ctx, input)}
| } else {
-   |   $stopEarly = true;
+   |   // Do nothing
--- End diff --

yea, I thinks so... I'm currently looking for other approaches.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15980: [SPARK-18528][SQL] Fix a bug to initialise an ite...

2016-11-23 Thread davies
Github user davies commented on a diff in the pull request:

https://github.com/apache/spark/pull/15980#discussion_r89365636
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala ---
@@ -67,23 +67,14 @@ trait BaseLimitExec extends UnaryExecNode with 
CodegenSupport {
   }
 
   override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: 
ExprCode): String = {
-val stopEarly = ctx.freshName("stopEarly")
-ctx.addMutableState("boolean", stopEarly, s"$stopEarly = false;")
-
-ctx.addNewFunction("shouldStop", s"""
-  @Override
-  protected boolean shouldStop() {
-return !currentRows.isEmpty() || $stopEarly;
-  }
-""")
 val countTerm = ctx.freshName("count")
 ctx.addMutableState("int", countTerm, s"$countTerm = 0;")
 s"""
| if ($countTerm < $limit) {
|   $countTerm += 1;
|   ${consume(ctx, input)}
| } else {
-   |   $stopEarly = true;
+   |   // Do nothing
--- End diff --

This removes a optimization, I don't think this is a good fix. Can we 
initialize it properly?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #15980: [SPARK-18528][SQL] Fix a bug to initialise an ite...

2016-11-22 Thread maropu
GitHub user maropu opened a pull request:

https://github.com/apache/spark/pull/15980

[SPARK-18528][SQL] Fix a bug to initialise an iterator of aggregation 
buffer 

## What changes were proposed in this pull request?
This pr is to fix an `NullPointerException` issue caused by a following 
`limit + aggregate` query;
```
scala> val df = Seq(("a", 1), ("b", 2), ("c", 1), ("d", 5)).toDF("id", 
"value")
scala> df.limit(2).groupBy("id").count().show
WARN TaskSetManager: Lost task 0.0 in stage 9.0 (TID 8204, 
lvsp20hdn012.stubprod.com): java.lang.NullPointerException
at 
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.agg_doAggregateWithKeys$(Unknown
 Source)
at 
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.processNext(Unknown
 Source)
```
The root culprit is that 
[`$doAgg()`](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L596)
 skips an initialization of [the buffer 
iterator](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L603);
 `BaseLimitExec` sets `stopEarly=true` and `$doAgg()` exits in the middle 
without the initialization.

## How was this patch tested?
Added a test to check if no exception happens for limit + aggregates in 
`DataFrameAggregateSuite.scala`.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/maropu/spark SPARK-18528

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/15980.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #15980


commit 31cf318358365fcd237fd9a9ec4f3125996f7e3e
Author: Takeshi YAMAMURO 
Date:   2016-11-22T19:18:22Z

Fix a bug to skip the init of hashmap




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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