Skip to content

Commit 1eda3a6

Browse files
committed
error handling
1 parent 6166b4e commit 1eda3a6

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

spark/src/test/scala/org/apache/spark/sql/comet/CometPlanStabilitySuite.scala

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,40 @@ trait CometPlanStabilitySuite extends DisableAdaptiveExecutionSuite with TPCDSBa
199199
* "sum(sr_return_amt#14)", so we remove all of these using regex
200200
*/
201201
def cleanUpReferences(references: AttributeSet): String = {
202-
referenceRegex.replaceAllIn(references.map(_.name).mkString(","), "")
202+
try {
203+
referenceRegex.replaceAllIn(references.map(_.name).mkString(","), "")
204+
} catch {
205+
case e: Exception =>
206+
s"[Error processing references: ${e.getMessage}]"
207+
}
203208
}
204209

205210
/**
206211
* Generate a simplified plan as a string Example output: TakeOrderedAndProject
207212
* [c_customer_id] WholeStageCodegen Project [c_customer_id]
208213
*/
209214
def simplifyNode(node: SparkPlan, depth: Int): String = {
210-
val padding = " " * depth
211-
var thisNode = node.nodeName
212-
if (node.references.nonEmpty) {
213-
thisNode += s" [${cleanUpReferences(node.references)}]"
214-
}
215-
if (node.producedAttributes.nonEmpty) {
216-
thisNode += s" [${cleanUpReferences(node.producedAttributes)}]"
217-
}
218-
val id = getId(node)
219-
if (id > 0) {
220-
thisNode += s" #$id"
215+
try {
216+
val padding = " " * depth
217+
var thisNode = node.nodeName
218+
if (node.references.nonEmpty) {
219+
thisNode += s" [${cleanUpReferences(node.references)}]"
220+
}
221+
if (node.producedAttributes.nonEmpty) {
222+
thisNode += s" [${cleanUpReferences(node.producedAttributes)}]"
223+
}
224+
val id = getId(node)
225+
if (id > 0) {
226+
thisNode += s" #$id"
227+
}
228+
val childrenSimplified = node.children.map(simplifyNode(_, depth + 1))
229+
val subqueriesSimplified = node.subqueries.map(simplifyNode(_, depth + 1))
230+
s"$padding$thisNode\n${subqueriesSimplified.mkString("")}${childrenSimplified.mkString("")}"
231+
} catch {
232+
case e: Exception =>
233+
val padding = " " * depth
234+
s"$padding[Error processing node ${node.getClass.getSimpleName}: ${e.getMessage}]"
221235
}
222-
val childrenSimplified = node.children.map(simplifyNode(_, depth + 1))
223-
val subqueriesSimplified = node.subqueries.map(simplifyNode(_, depth + 1))
224-
s"$padding$thisNode\n${subqueriesSimplified.mkString("")}${childrenSimplified.mkString("")}"
225236
}
226237

227238
simplifyNode(plan, 0)

0 commit comments

Comments
 (0)