Skip to content

Commit 43cd6ca

Browse files
beliefercloud-fan
authored andcommitted
[SPARK-35378][SQL][FOLLOWUP] isLocal should consider CommandResult
### What changes were proposed in this pull request? apache#32513 added the case class `CommandResult` so as we can eagerly execute command locally. But we forgot to update `isLocal` of `Dataset`. ### Why are the changes needed? `Dataset.isLocal` should consider `CommandResult`. ### Does this PR introduce _any_ user-facing change? Yes. If the SQL plan is `CommandResult`, `Dataset.isLocal` must return true. ### How was this patch tested? No test. Closes apache#32963 from beliefer/SPARK-35378-followup2. Authored-by: gengjiaan <gengjiaan@360.cn> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
1 parent d4d11cf commit 43cd6ca

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ class Dataset[T] private[sql](
597597
* @group basic
598598
* @since 1.6.0
599599
*/
600-
def isLocal: Boolean = logicalPlan.isInstanceOf[LocalRelation]
600+
def isLocal: Boolean = logicalPlan.isInstanceOf[LocalRelation] ||
601+
logicalPlan.isInstanceOf[CommandResult]
601602

602603
/**
603604
* Returns true if the `Dataset` is empty.

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,6 +2907,13 @@ class DataFrameSuite extends QueryTest
29072907
}
29082908
}
29092909
}
2910+
2911+
test("isLocal should consider CommandResult and LocalRelation") {
2912+
val df1 = sql("SHOW TABLES")
2913+
assert(df1.isLocal)
2914+
val df2 = (1 to 10).toDF()
2915+
assert(df2.isLocal)
2916+
}
29102917
}
29112918

29122919
case class GroupByKey(a: Int, b: Int)

0 commit comments

Comments
 (0)