aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src
diff options
context:
space:
mode:
authorGregory Hart <greg.hart@thinkbiganalytics.com>2016-04-28 11:21:43 -0700
committerReynold Xin <rxin@databricks.com>2016-04-28 11:21:43 -0700
commit12c360c057f09d13a31c458ad277640b5f6de394 (patch)
tree47640c64668b77ea7dc6d6cb86913e4bc618c91f /sql/catalyst/src
parent89addd40abdacd65cc03ac8aa5f9cf3dd4a4c19b (diff)
downloadspark-12c360c057f09d13a31c458ad277640b5f6de394.tar.gz
spark-12c360c057f09d13a31c458ad277640b5f6de394.tar.bz2
spark-12c360c057f09d13a31c458ad277640b5f6de394.zip
[SPARK-14965][SQL] Indicate an exception is thrown for a missing struct field
## What changes were proposed in this pull request? Fix to ScalaDoc for StructType. ## How was this patch tested? Built locally. Author: Gregory Hart <greg.hart@thinkbiganalytics.com> Closes #12758 from freastro/hotfix/SPARK-14965.
Diffstat (limited to 'sql/catalyst/src')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
index 1238eefcb6..6f50be7a99 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
@@ -206,8 +206,9 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
}
/**
- * Extracts a [[StructField]] of the given name. If the [[StructType]] object does not
- * have a name matching the given name, `null` will be returned.
+ * Extracts the [[StructField]] with the given name.
+ *
+ * @throws IllegalArgumentException if a field with the given name does not exist
*/
def apply(name: String): StructField = {
nameToField.getOrElse(name,
@@ -216,7 +217,9 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
/**
* Returns a [[StructType]] containing [[StructField]]s of the given names, preserving the
- * original order of fields. Those names which do not have matching fields will be ignored.
+ * original order of fields.
+ *
+ * @throws IllegalArgumentException if a field cannot be found for any of the given names
*/
def apply(names: Set[String]): StructType = {
val nonExistFields = names -- fieldNamesSet
@@ -229,7 +232,9 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
}
/**
- * Returns index of a given field
+ * Returns the index of a given field.
+ *
+ * @throws IllegalArgumentException if a field with the given name does not exist
*/
def fieldIndex(name: String): Int = {
nameToIndex.getOrElse(name,