srowen closed pull request #20500: [SPARK-14023][MLlib] Make exceptions
consistent regarding fields and columns
URL: https://github.com/apache/spark/pull/20500
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 e3b0969283a84..c6c295487ecc6 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
@@ -57,7 +57,7 @@ import org.apache.spark.util.Utils
*
* // If this struct does not have a field called "d", it throws an exception.
* struct("d")
- * // java.lang.IllegalArgumentException: Field "d" does not exist.
+ * // java.lang.IllegalArgumentException: Column "d" does not exist.
* // ...
*
* // Extract multiple StructFields. Field names are provided in a set.
@@ -69,7 +69,7 @@ import org.apache.spark.util.Utils
* // Any names without matching fields will throw an exception.
* // For the case shown below, an exception is thrown due to "d".
* struct(Set("b", "c", "d"))
- * // java.lang.IllegalArgumentException: Field "d" does not exist.
+ * // java.lang.IllegalArgumentException: Column "d" does not exist.
* // ...
* }}}
*
@@ -260,24 +260,24 @@ case class StructType(fields: Array[StructField]) extends
DataType with Seq[Stru
/**
* Extracts the [[StructField]] with the given name.
*
- * @throws IllegalArgumentException if a field with the given name does not
exist
+ * @throws IllegalArgumentException if a column with the given name does not
exist
*/
def apply(name: String): StructField = {
nameToField.getOrElse(name,
- throw new IllegalArgumentException(s"""Field "$name" does not exist."""))
+ throw new IllegalArgumentException(s"""Column "$name" does not
exist."""))
}
/**
* Returns a [[StructType]] containing [[StructField]]s of the given names,
preserving the
* original order of fields.
*
- * @throws IllegalArgumentException if a field cannot be found for any of
the given names
+ * @throws IllegalArgumentException if a column cannot be found for any of
the given names
*/
def apply(names: Set[String]): StructType = {
val nonExistFields = names -- fieldNamesSet
if (nonExistFields.nonEmpty) {
throw new IllegalArgumentException(
- s"Field ${nonExistFields.mkString(",")} does not exist.")
+ s"Column ${nonExistFields.mkString(",")} does not exist.")
}
// Preserve the original order of fields.
StructType(fields.filter(f => names.contains(f.name)))
@@ -286,11 +286,11 @@ case class StructType(fields: Array[StructField]) extends
DataType with Seq[Stru
/**
* Returns the index of a given field.
*
- * @throws IllegalArgumentException if a field with the given name does not
exist
+ * @throws IllegalArgumentException if a column with the given name does not
exist
*/
def fieldIndex(name: String): Int = {
nameToIndex.getOrElse(name,
- throw new IllegalArgumentException(s"""Field "$name" does not exist."""))
+ throw new IllegalArgumentException(s"""Column "$name" does not
exist."""))
}
private[sql] def getFieldIndex(name: String): Option[Int] = {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]