spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lix...@apache.org
Subject spark git commit: [SPARK-20873][SQL] Improve the error message for unsupported Column Type
Date Fri, 26 May 2017 22:07:38 GMT
Repository: spark
Updated Branches:
  refs/heads/master ae33abf71 -> c491e2ed9


[SPARK-20873][SQL] Improve the error message for unsupported Column Type

## What changes were proposed in this pull request?
Upon encountering an invalid columntype, the column type object is printed, rather than the
type.
This  change improves this by outputting its name.

## How was this patch tested?
Added a simple  unit test to verify the contents of the raised exception

Author: setjet <rubenljanssen@gmail.com>

Closes #18097 from setjet/spark-20873.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c491e2ed
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c491e2ed
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c491e2ed

Branch: refs/heads/master
Commit: c491e2ed90afc980d197d54cb965213bdd192b4b
Parents: ae33abf
Author: setjet <rubenljanssen@gmail.com>
Authored: Fri May 26 15:07:28 2017 -0700
Committer: Xiao Li <gatorsmile@gmail.com>
Committed: Fri May 26 15:07:28 2017 -0700

----------------------------------------------------------------------
 .../spark/sql/execution/columnar/ColumnType.scala     |  2 +-
 .../sql/execution/columnar/ColumnTypeSuite.scala      | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/c491e2ed/sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
b/sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
index 703bde2..5cfb003 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
@@ -684,7 +684,7 @@ private[columnar] object ColumnType {
       case struct: StructType => STRUCT(struct)
       case udt: UserDefinedType[_] => apply(udt.sqlType)
       case other =>
-        throw new Exception(s"Unsupported type: $other")
+        throw new Exception(s"Unsupported type: ${other.simpleString}")
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/spark/blob/c491e2ed/sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/ColumnTypeSuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/ColumnTypeSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/ColumnTypeSuite.scala
index 5f2a3aa..ff05049 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/ColumnTypeSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/ColumnTypeSuite.scala
@@ -144,4 +144,18 @@ class ColumnTypeSuite extends SparkFunSuite with Logging {
       ColumnType(DecimalType(19, 0))
     }
   }
+
+  test("show type name in type mismatch error") {
+    val invalidType = new DataType {
+        override def defaultSize: Int = 1
+        override private[spark] def asNullable: DataType = this
+        override def typeName: String = "invalid type name"
+    }
+
+    val message = intercept[java.lang.Exception] {
+      ColumnType(invalidType)
+    }.getMessage
+
+    assert(message.contains("Unsupported type: invalid type name"))
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message