Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 29.4k
[SPARK-30362][Core] Update InputMetrics in DataSourceRDD#27021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,9 +16,12 @@ | ||
| */ | ||
| package org.apache.spark.sql.execution | ||
| import scala.collection.mutable | ||
| import org.apache.hadoop.fs.Path | ||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd} | ||
| import org.apache.spark.sql.{DataFrame, QueryTest} | ||
| import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
| import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan | ||
| @@ -167,4 +170,33 @@ class DataSourceV2ScanExecRedactionSuite extends DataSourceScanRedactionTest { | ||
| } | ||
| } | ||
| } | ||
| test("SPARK-30362: test input metrics for DSV2") { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to actually test DSV2, let's call | ||
| withSQLConf(SQLConf.USE_V1_SOURCE_LIST.key -> "") { | ||
| Seq("json", "orc", "parquet").foreach { format => | ||
| withTempPath { path => | ||
| val dir = path.getCanonicalPath | ||
| spark.range(0, 10).write.format(format).save(dir) | ||
| val df = spark.read.format(format).load(dir) | ||
| val bytesReads = new mutable.ArrayBuffer[Long]() | ||
| val recordsRead = new mutable.ArrayBuffer[Long]() | ||
| val bytesReadListener = new SparkListener() { | ||
| override def onTaskEnd(taskEnd: SparkListenerTaskEnd): Unit = { | ||
| bytesReads += taskEnd.taskMetrics.inputMetrics.bytesRead | ||
| recordsRead += taskEnd.taskMetrics.inputMetrics.recordsRead | ||
| } | ||
| } | ||
| sparkContext.addSparkListener(bytesReadListener) | ||
| try { | ||
| df.collect() | ||
| sparkContext.listenerBus.waitUntilEmpty() | ||
| assert(bytesReads.sum > 0) | ||
| assert(recordsRead.sum == 10) | ||
| } finally { | ||
| sparkContext.removeSparkListener(bytesReadListener) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to be consistent, let's have a
MetricsRowIterator, and the base classMetricsIteratordoesn't need to implementnextThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or the base class can implement
nextas