-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Partho Sarthi <psarthi@nvidia.com>
- Loading branch information
Showing
8 changed files
with
136 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/test/resources/QualificationExpectations/photon_eventlog_expectation.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
App Name,App ID,Estimated GPU Duration,Estimated GPU Time Saved,SQL DF Duration,SQL Dataframe Task Duration,App Duration,GPU Opportunity,Executor CPU Time Percent,SQL Ids with Failures,Unsupported Read File Formats and Types,Unsupported Write Data Format,Complex Types,Nested Complex Types,Potential Problems,Longest SQL Duration,SQL Stage Durations Sum,NONSQL Task Duration Plus Overhead,Unsupported Task Duration,Supported SQL DF Task Duration,App Duration Estimated,Unsupported Execs,Unsupported Expressions,Estimated Job Frequency (monthly),Total Core Seconds,Photon App | ||
"Spark shell","local-1629446106683",16424.61,1273.38,1910,6475,17698,1910,27.76,"","","","array<struct<city:string,state:string>>;map<string,map<string,string>>","array<struct<city:string,state:string>>;map<string,map<string,string>>","NESTED COMPLEX TYPE",1453,1203,16292,0,6475,false,"","",30,132,true | ||
"Databricks Shell","app-20240919162642-0000",205952.38,195501.61,258770,3858136,401454,258770,75.53,"","","","","","",250542,1810943,598848,0,3858136,true,"Execute AddJarsCommand;Execute CreateViewCommand","",30,6213,true |
Binary file added
BIN
+3.31 MB
core/src/test/resources/spark-events-qualification/nds_q88_photon_db_13_3.zstd
Binary file not shown.
Binary file removed
BIN
-58 KB
core/src/test/resources/spark-events-qualification/photon_eventlog.zstd
Binary file not shown.
82 changes: 82 additions & 0 deletions
82
core/src/test/scala/com/nvidia/spark/rapids/tool/planparser/BasePlanParserSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nvidia.spark.rapids.tool.planparser | ||
|
||
import com.nvidia.spark.rapids.BaseTestSuite | ||
import com.nvidia.spark.rapids.tool.{EventLogPathProcessor, ToolTestUtils} | ||
import com.nvidia.spark.rapids.tool.qualification._ | ||
|
||
import org.apache.spark.sql.rapids.tool.qualification.QualificationAppInfo | ||
import org.apache.spark.sql.rapids.tool.util.RapidsToolsConfUtil | ||
|
||
class BasePlanParserSuite extends BaseTestSuite { | ||
|
||
val profileLogDir: String = ToolTestUtils.getTestResourcePath("spark-events-profiling") | ||
val qualLogDir: String = ToolTestUtils.getTestResourcePath("spark-events-qualification") | ||
|
||
def assertSizeAndNotSupported(size: Int, execs: Seq[ExecInfo], | ||
checkDurations: Boolean = true): Unit = { | ||
for (t <- Seq(execs)) { | ||
assert(t.size == size, t) | ||
assert(t.forall(_.speedupFactor == 1), t) | ||
assert(t.forall(_.isSupported == false), t) | ||
assert(t.forall(_.children.isEmpty), t) | ||
if (checkDurations) { | ||
assert(t.forall(_.duration.isEmpty), t) | ||
} | ||
} | ||
} | ||
|
||
def assertSizeAndSupported(size: Int, execs: Seq[ExecInfo], | ||
expectedDur: Seq[Option[Long]] = Seq.empty, extraText: String = "", | ||
checkDurations: Boolean = true): Unit = { | ||
for (t <- Seq(execs)) { | ||
assert(t.size == size, s"$extraText $t") | ||
assert(t.forall(_.isSupported == true), s"$extraText $t") | ||
assert(t.forall(_.children.isEmpty), s"$extraText $t") | ||
if (expectedDur.nonEmpty) { | ||
val durations = t.map(_.duration) | ||
assert(durations.diff(expectedDur).isEmpty, | ||
s"$extraText durations differ expected ${expectedDur.mkString(",")} " + | ||
s"but got ${durations.mkString(",")}") | ||
} else if (checkDurations) { | ||
assert(t.forall(_.duration.isEmpty), s"$extraText $t") | ||
} | ||
} | ||
} | ||
|
||
def createAppFromEventlog(eventLog: String): QualificationAppInfo = { | ||
val hadoopConf = RapidsToolsConfUtil.newHadoopConf() | ||
val (_, allEventLogs) = EventLogPathProcessor.processAllPaths( | ||
None, None, List(eventLog), hadoopConf) | ||
val pluginTypeChecker = new PluginTypeChecker() | ||
assert(allEventLogs.size == 1) | ||
val appResult = QualificationAppInfo.createApp(allEventLogs.head, hadoopConf, | ||
pluginTypeChecker, reportSqlLevel = false, mlOpsEnabled = false, penalizeTransitions = true) | ||
appResult match { | ||
case Right(app) => app | ||
case Left(_) => throw new AssertionError("Cannot create application") | ||
} | ||
} | ||
|
||
def getAllExecsFromPlan(plans: Seq[PlanInfo]): Seq[ExecInfo] = { | ||
val topExecInfo = plans.flatMap(_.execInfo) | ||
topExecInfo.flatMap { e => | ||
e.children.getOrElse(Seq.empty) :+ e | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
core/src/test/scala/com/nvidia/spark/rapids/tool/planparser/PhotonPlanParserSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nvidia.spark.rapids.tool.planparser | ||
|
||
import com.nvidia.spark.rapids.tool.qualification.PluginTypeChecker | ||
|
||
|
||
class PhotonPlanParserSuite extends BasePlanParserSuite { | ||
|
||
// scalastyle:off line.size.limit | ||
// Test cases for Photon nodes. We could add more operators here. | ||
val photonOpTestCases: Seq[(String, String)] = Seq( | ||
"PhotonBroadcastNestedLoopJoin" -> "BroadcastNestedLoopJoin", // Case: Photon specific parser | ||
"PhotonProject" -> "Project", // Case: Fallback to Spark CPU parser | ||
"PhotonShuffleMapStage" -> "WholeStageCodegen" // Case: WholeStageCodegen operator | ||
) | ||
// scalastyle:on line.size.limit | ||
|
||
photonOpTestCases.foreach { case (photonName, sparkName) => | ||
test(s"$photonName is parsed as Spark $sparkName") { | ||
val eventLog = s"$qualLogDir/nds_q88_photon_db_13_3.zstd" | ||
val pluginTypeChecker = new PluginTypeChecker() | ||
val app = createAppFromEventlog(eventLog) | ||
assert(app.sqlPlans.nonEmpty) | ||
val parsedPlans = app.sqlPlans.map { case (sqlID, plan) => | ||
SQLPlanParser.parseSQLPlan(app.appId, plan, sqlID, "", pluginTypeChecker, app) | ||
} | ||
val allExecInfo = getAllExecsFromPlan(parsedPlans.toSeq) | ||
val reader = allExecInfo.filter(_.exec.contains(sparkName)) | ||
assert(reader.nonEmpty, s"Failed to find $sparkName in $allExecInfo") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters