Uh oh!
There was an error while loading. Please reload this page.
[SPARK-34234][SQL] Remove TreeNodeException that didn't work - #31337
[SPARK-34234][SQL] Remove TreeNodeException that didn't work#31337beliefer wants to merge 13 commits into
Conversation
SparkQA
commented
Jan 26, 2021
Kubernetes integration test starting |
SparkQA
commented
Jan 26, 2021
Kubernetes integration test status failure |
SparkQA
commented
Jan 26, 2021
Test build #134476 has finished for PR 31337 at commit
|
SparkQA
commented
Jan 26, 2021
Kubernetes integration test starting |
SparkQA
commented
Jan 26, 2021
Kubernetes integration test status success |
SparkQA
commented
Jan 26, 2021
Test build #134501 has finished for PR 31337 at commit
|
beliefer
commented
Jan 27, 2021
cc @cloud-fan |
| a | ||
| } else { | ||
| BoundReference(ordinal, a.dataType, input(ordinal).nullable) | ||
| sys.error(s"Couldn't find $a in ${input.attrs.mkString("[", ",", "]")}") |
There was a problem hiding this comment.
since we are here, let's change it to throw new IllegalStateException, as sys.error exists the JVM.
| @@ -35,7 +35,7 @@ import org.apache.spark.sql.util.CaseInsensitiveStringMap | |||
| * resolved. | |||
| */ | |||
| class UnresolvedException[TreeType <: TreeNode[_]](tree: TreeType, function: String) | |||
There was a problem hiding this comment.
Seems we don't need the tree parameter
cloud-fan
commented
Feb 5, 2021
maropu
commented
Feb 5, 2021
yea, removing it looks fine. |
| |${sideBySide(plan.treeString, reOptimized.treeString).mkString("\n")} | ||
| """.stripMargin | ||
| throw new TreeNodeException(reOptimized, message, null) | ||
| throw new AnalysisException(message) |
There was a problem hiding this comment.
Is this always an analysis exception? Seems to me it is not only for analyzer rule.
There was a problem hiding this comment.
For a place like this, should we keep tree node exception?
There was a problem hiding this comment.
TreeNodeException makes stacktrace verbose and complicated. Yeah! it was work for analyzer, optimizer and expressions, do we need to create RuleExeception? or you have another idea.
There was a problem hiding this comment.
RuntimeException is also fine. It's test-only and most likely people don't care about exception type here.
| } | ||
| } | ||
| protected override def doExecute(): RDD[InternalRow] = attachTree(this, "execute") { |
There was a problem hiding this comment.
Removing tree node exception for a place like this looks good to me. The error happened here should not be node tree related.
SparkQA
commented
Feb 7, 2021
Test build #134975 has finished for PR 31337 at commit
|
SparkQA
commented
Feb 7, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 7, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 7, 2021
Kubernetes integration test status success |
SparkQA
commented
Feb 7, 2021
Test build #134976 has finished for PR 31337 at commit
|
SparkQA
commented
Feb 7, 2021
Kubernetes integration test status success |
beliefer
commented
Feb 7, 2021
retest this please |
SparkQA
commented
Feb 7, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 7, 2021
Kubernetes integration test status success |
SparkQA
commented
Feb 9, 2021
Test build #135062 has finished for PR 31337 at commit
|
SparkQA
commented
Feb 9, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 9, 2021
Test build #135065 has finished for PR 31337 at commit
|
SparkQA
commented
Feb 9, 2021
Kubernetes integration test status success |
SparkQA
commented
Feb 9, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 9, 2021
Kubernetes integration test status failure |
SparkQA
commented
Feb 9, 2021
Test build #135068 has finished for PR 31337 at commit
|
beliefer
commented
Feb 10, 2021
cc @cloud-fan |
| /** | ||
| * Functions for attaching and retrieving trees that are associated with errors. | ||
| */ | ||
| package object errors { |
| a | ||
| } else { | ||
| BoundReference(ordinal, a.dataType, input(ordinal).nullable) | ||
| throw QueryExecutionErrors.cannotFindExpressionInInputAttributesError(a, input) |
There was a problem hiding this comment.
nit: previously it's sys.error, which means it's something that shouldn't hit. I think it's also assert-like and we can just use IllegalStateException here.
There was a problem hiding this comment.
Yeah. It hears more reasonable.
SparkQA
commented
Feb 10, 2021
Kubernetes integration test starting |
SparkQA
commented
Feb 10, 2021
Kubernetes integration test status success |
cloud-fan
commented
Feb 10, 2021
thanks, merging to master! |
beliefer
commented
Feb 10, 2021
@cloud-fan Thanks for your work! @maropu@viirya Thanks for your review! |
SparkQA
commented
Feb 10, 2021
Test build #135088 has finished for PR 31337 at commit
|
SparkQA
commented
Feb 10, 2021
Test build #135089 has finished for PR 31337 at commit
|
| throw new IllegalStateException( | ||
| s"Couldn't find $a in ${input.attrs.mkString("[", ",", "]")}") |
There was a problem hiding this comment.
Is it supposed an internal error, correct? or end users might face to the error on some SQL queries?
There was a problem hiding this comment.
I guess we should use internal error too. At that time, we didn't have this understanding yet.
pan3793
commented
Nov 6, 2025
@beliefer@cloud-fan I understand that the intention of this change is to eliminate redundant messages for internal errors that occur during the SparkPlan execution. But I think it makes the error message less useful if something goes wrong in the analyze or optimize phases. For example, I hit an error that happens in the rule the below stacktrace comes from the internal version based on OSS Spark 3.3 |
beliefer
commented
Nov 6, 2025
It seems the |
pan3793
commented
Nov 6, 2025
@beliefer, absolutely right, but which node? I expect a sub-plan tree to be printed to narrow the scope from a huge whole plan tree. |
cloud-fan
commented
Nov 6, 2025
so |
beliefer
commented
Nov 7, 2025
Got it. I have no idea if it is worth to keep. I think we can print more info for |
What changes were proposed in this pull request?
TreeNodeExceptioncauses the error msg not clear and it didn't work well.Because the
TreeNodeExceptionlooks redundancy, we could remove it.There are show a case:
The above code will use
HashAggregateExec. In order to ensure that an exception will be thrown when executingHashAggregateExec, I addedthrow new RuntimeException("calculate error")intospark/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala
Line 85 in 72b7f8a
So, if the above code is executed,
RuntimeException("calculate error")will be thrown.Before this PR, the error is:
After this PR, the error is:
Why are the changes needed?
TreeNodeExceptiondidn't work well.Does this PR introduce any user-facing change?
'No'.
How was this patch tested?
Jenkins test.