Skip to content

Commit fb74c83

Browse files
committed
Remove quotes
1 parent 9979df7 commit fb74c83

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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] = {

sql/catalyst/src/test/scala/org/apache/spark/sql/types/StructTypeSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ class StructTypeSuite extends SparkFunSuite {
2626

2727
test("lookup a single missing field should output existing fields") {
2828
val e = intercept[IllegalArgumentException](s("c")).getMessage
29-
assert(e.contains("Available: \"a\", \"b\""))
29+
assert(e.contains("Available: a, b"))
3030
}
3131

3232
test("lookup a set of missing fields should output existing fields") {
3333
val e = intercept[IllegalArgumentException](s(Set("a", "c"))).getMessage
34-
assert(e.contains("Available: \"a\", \"b\""))
34+
assert(e.contains("Available: a, b"))
3535
}
3636

3737
test("lookup fieldIndex for missing field should output existing fields") {
3838
val e = intercept[IllegalArgumentException](s.fieldIndex("c")).getMessage
39-
assert(e.contains("Available: \"a\", \"b\""))
39+
assert(e.contains("Available: a, b"))
4040
}
4141

4242
test("SPARK-24849: toDDL - simple struct") {

0 commit comments

Comments
 (0)