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 1238eefcb6062c56187546fd207579e0bc9da150..6f50be7a99c5e62f8cb48bf64851b5d513808f3c 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,