Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ public long durationMs() {
*/
public abstract void init(int index, Iterator<InternalRow>[] iters);

/*
* Attributes of the following four methods are public. Thus, they can be also accessed from
* methods in inner classes. See SPARK-23598
*/
/**
* Append a row to currentRows.
*/
protected void append(InternalRow row) {
public void append(InternalRow row) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Although we added the test, should we also add a short sentence that said this is public so inner classes can also access it?

currentRows.add(row);
}

Expand All @@ -75,7 +79,7 @@ protected void append(InternalRow row) {
* If it returns true, the caller should exit the loop that [[InputAdapter]] generates.
* This interface is mainly used to limit the number of input rows.
*/
protected boolean stopEarly() {
public boolean stopEarly() {
return false;
}

Expand All @@ -84,14 +88,14 @@ protected boolean stopEarly() {
*
* If it returns true, the caller should exit the loop (return from processNext()).
*/
protected boolean shouldStop() {
public boolean shouldStop() {
return !currentRows.isEmpty();
}

/**
* Increase the peak execution memory for current task.
*/
protected void incPeakExecutionMemory(long size) {
public void incPeakExecutionMemory(long size) {
TaskContext.get().taskMetrics().incPeakExecutionMemory(size);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import org.apache.spark.sql.types.{IntegerType, StringType, StructType}

class WholeStageCodegenSuite extends QueryTest with SharedSQLContext {

import testImplicits._

test("range/filter should be combined") {
val df = spark.range(10).filter("id = 1").selectExpr("id + 1")
val plan = df.queryExecution.executedPlan
Expand Down Expand Up @@ -307,4 +309,14 @@ class WholeStageCodegenSuite extends QueryTest with SharedSQLContext {
// a different query can result in codegen cache miss, that's by design
}
}

test("SPARK-23598: Codegen working for lots of aggregation operations without runtime errors") {
withSQLConf(SQLConf.SHUFFLE_PARTITIONS.key -> "1") {
var df = Seq((8, "bat"), (15, "mouse"), (5, "horse")).toDF("age", "name")
for (i <- 0 until 70) {
df = df.groupBy("name").agg(avg("age").alias("age"))
}
assert(df.limit(1).collect() === Array(Row("bat", 8.0)))
}
}
}