Skip to content
Snippets Groups Projects
Commit 52d4f619 authored by Dongjoon Hyun's avatar Dongjoon Hyun Committed by Wenchen Fan
Browse files

[SPARK-18909][SQL] The error messages in `ExpressionEncoder.toRow/fromRow` are too verbose

## What changes were proposed in this pull request?

In `ExpressionEncoder.toRow` and `fromRow`, we catch the exception and output `treeString` of serializer/deserializer expressions in the error message. However, encoder can be very complex and the serializer/deserializer expressions can be very large trees and blow up the log files(e.g. generate over 500mb logs for this single error message.) As a first attempt, this PR try to use `simpleString` instead.

**BEFORE**

```scala
scala> :paste
// Entering paste mode (ctrl-D to finish)

case class TestCaseClass(value: Int)
import spark.implicits._
Seq(TestCaseClass(1)).toDS().collect()

// Exiting paste mode, now interpreting.

java.lang.RuntimeException: Error while decoding: java.lang.NullPointerException
newInstance(class TestCaseClass)
+- assertnotnull(input[0, int, false], - field (class: "scala.Int", name: "value"), - root class: "TestCaseClass")
   +- input[0, int, false]

  at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.fromRow(ExpressionEncoder.scala:303)
...
```

**AFTER**

```scala
...
// Exiting paste mode, now interpreting.

java.lang.RuntimeException: Error while decoding: java.lang.NullPointerException
newInstance(class TestCaseClass)
  at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.fromRow(ExpressionEncoder.scala:303)
...
```

## How was this patch tested?

Manual.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #16701 from dongjoon-hyun/SPARK-18909-EXPR-ERROR.
parent 20b4ca14
No related branches found
No related tags found
No related merge requests found
...@@ -288,7 +288,7 @@ case class ExpressionEncoder[T]( ...@@ -288,7 +288,7 @@ case class ExpressionEncoder[T](
} catch { } catch {
case e: Exception => case e: Exception =>
throw new RuntimeException( throw new RuntimeException(
s"Error while encoding: $e\n${serializer.map(_.treeString).mkString("\n")}", e) s"Error while encoding: $e\n${serializer.map(_.simpleString).mkString("\n")}", e)
} }
/** /**
...@@ -300,7 +300,7 @@ case class ExpressionEncoder[T]( ...@@ -300,7 +300,7 @@ case class ExpressionEncoder[T](
constructProjection(row).get(0, ObjectType(clsTag.runtimeClass)).asInstanceOf[T] constructProjection(row).get(0, ObjectType(clsTag.runtimeClass)).asInstanceOf[T]
} catch { } catch {
case e: Exception => case e: Exception =>
throw new RuntimeException(s"Error while decoding: $e\n${deserializer.treeString}", e) throw new RuntimeException(s"Error while decoding: $e\n${deserializer.simpleString}", e)
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment