@@ -56,7 +56,7 @@ import org.apache.spark.sql.catalyst.util.{quoteIdentifier, truncatedString}
5656 *
5757 * // If this struct does not have a field called "d", it throws an exception.
5858 * struct("d")
59- * // java.lang.IllegalArgumentException: "d" does not exist.
59+ * // java.lang.IllegalArgumentException: d does not exist.
6060 * // ...
6161 *
6262 * // Extract multiple StructFields. Field names are provided in a set.
@@ -68,7 +68,7 @@ import org.apache.spark.sql.catalyst.util.{quoteIdentifier, truncatedString}
6868 * // Any names without matching fields will throw an exception.
6969 * // For the case shown below, an exception is thrown due to "d".
7070 * struct(Set("b", "c", "d"))
71- * // java.lang.IllegalArgumentException: "d" does not exist.
71+ * // java.lang.IllegalArgumentException: d does not exist.
7272 * // ...
7373 * }}}
7474 *
@@ -271,22 +271,21 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
271271 def apply (name : String ): StructField = {
272272 nameToField.getOrElse(name,
273273 throw new IllegalArgumentException (
274- s """ " $name" does not exist.
275- |Available: ${fieldNames.mkString(" \" " , " \" , \" " , " \" " )}""" .stripMargin))
274+ s " $name does not exist. Available: ${fieldNames.mkString(" , " )}" ))
276275 }
277276
278277 /**
279278 * Returns a [[StructType ]] containing [[StructField ]]s of the given names, preserving the
280279 * original order of fields.
281280 *
282- * @throws IllegalArgumentException if a field cannot be found for any of the given names
281+ * @throws IllegalArgumentException if at least one given field name does not exist
283282 */
284283 def apply (names : Set [String ]): StructType = {
285284 val nonExistFields = names -- fieldNamesSet
286285 if (nonExistFields.nonEmpty) {
287286 throw new IllegalArgumentException (
288- s """ ${nonExistFields.mkString(" , " )} do(es) not exist.
289- | Available: ${fieldNames.mkString(" \" " , " \" , \" " , " \" " )}""" .stripMargin )
287+ s " ${nonExistFields.mkString(" , " )} do(es) not exist. " +
288+ s " Available: ${fieldNames.mkString(" , " )}" )
290289 }
291290 // Preserve the original order of fields.
292291 StructType (fields.filter(f => names.contains(f.name)))
@@ -300,8 +299,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
300299 def fieldIndex (name : String ): Int = {
301300 nameToIndex.getOrElse(name,
302301 throw new IllegalArgumentException (
303- s """ " $name" does not exist.
304- |Available: ${fieldNames.mkString(" \" " , " \" , \" " , " \" " )}""" .stripMargin))
302+ s " $name does not exist. Available: ${fieldNames.mkString(" , " )}" ))
305303 }
306304
307305 private [sql] def getFieldIndex (name : String ): Option [Int ] = {
0 commit comments