Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
count() shouldn't show sql text
  • Loading branch information
LantaoJin committed Mar 19, 2018
commit df98d83a2ebc194864716f08636163905e2fd114
10 changes: 7 additions & 3 deletions sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ class Dataset[T] private[sql](
* @group action
* @since 1.6.0
*/
def count(): Long = withAction("count", groupBy().count().queryExecution) { plan =>
def count(): Long = withAction("count", groupBy().count().queryExecution, true) { plan =>
plan.executeCollect().head.getLong(0)
}

Expand Down Expand Up @@ -3257,13 +3257,17 @@ class Dataset[T] private[sql](
* Wrap a Dataset action to track the QueryExecution and time cost, then report to the
* user-registered callback functions.
*/
private def withAction[U](name: String, qe: QueryExecution)(action: SparkPlan => U) = {
private def withAction[U](
name: String,
qe: QueryExecution,
hideSqlText: Boolean = false)(action: SparkPlan => U) = {
try {
qe.executedPlan.foreach { plan =>
plan.resetMetrics()
}
val start = System.nanoTime()
val result = SQLExecution.withNewExecutionId(sparkSession, qe, sqlText) {
val result = SQLExecution.withNewExecutionId(sparkSession, qe,
if (hideSqlText) "" else sqlText) {
action(qe.executedPlan)
}
val end = System.nanoTime()
Expand Down