forked from NVIDIA/spark-rapids-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Count expressions per Exec in SQLPlanParser
Signed-off-by: Ahmed Hussein (amahussein) <[email protected]> Fixes NVIDIA#1447 Improves the operators-stats by counting the occurence of each expression within the Exec node.
- Loading branch information
1 parent
a414e09
commit 1fba881
Showing
10 changed files
with
242 additions
and
109 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
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
31 changes: 31 additions & 0 deletions
31
core/src/main/scala/com/nvidia/spark/rapids/tool/planparser/ops/ExprOpRef.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,31 @@ | ||
/* | ||
* 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.ops | ||
|
||
/** | ||
* Represents a reference to an expression operator that is stored in the ExecInfo expressions | ||
* @param opRef the opRef to wrap | ||
* @param count the count of that expression within the exec. | ||
*/ | ||
case class ExprOpRef(opRef: OpRef, count: Int = 1) extends OpRefWrapperBase(opRef) | ||
|
||
object ExprOpRef extends OpRefWrapperBaseTrait[ExprOpRef] { | ||
def fromRawExprSeq(exprArr: Seq[String]): Seq[ExprOpRef] = { | ||
exprArr.groupBy(identity) | ||
.mapValues(expr => ExprOpRef(OpRef.fromExpr(expr.head), expr.size)).values.toSeq | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
core/src/main/scala/com/nvidia/spark/rapids/tool/planparser/ops/OpRefWrapperBase.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,50 @@ | ||
/* | ||
* 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.ops | ||
|
||
/** | ||
* An instance that wraps OpRef and exposes the OpRef methods. | ||
* This is used to provide common interface for all classes that wrap OpRef along with other | ||
* metadata. | ||
* @param opRef the opRef to wrap | ||
*/ | ||
class OpRefWrapperBase(opRef: OpRef) extends OperatorRefTrait { | ||
override def getOpName: String = opRef.getOpName | ||
|
||
override def getOpNameCSV: String = opRef.getOpNameCSV | ||
|
||
override def getOpType: String = opRef.getOpType | ||
|
||
override def getOpTypeCSV: String = opRef.getOpTypeCSV | ||
|
||
def getOpRef: OpRef = opRef | ||
} | ||
|
||
/** | ||
* A trait that provides a factory method to create instances of OpRefWrapperBase from a sequence of | ||
* @tparam R the type of the OpRefWrapperBase | ||
*/ | ||
trait OpRefWrapperBaseTrait[R <: OpRefWrapperBase] { | ||
/** | ||
* Create instances of OpRefWrapperBase from a sequence of expressions. | ||
* The expressions are grouped by their value and the count of each expression is stored in the | ||
* OpRefWrapperBase entry. | ||
* @param exprArr the sequence of expressions | ||
* @return a sequence of OpRefWrapperBase instances | ||
*/ | ||
def fromRawExprSeq(exprArr: Seq[String]): Seq[R] | ||
} |
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
Oops, something went wrong.