Skip to content

Commit 78e037d

Browse files
committed
use fieldNames to preserve order
1 parent b2d1888 commit 78e037d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
273273
nameToField.getOrElse(name,
274274
throw new IllegalArgumentException(
275275
s"""Field "$name" does not exist.
276-
|Available fields: ${fieldNamesSet.mkString(", ")}""".stripMargin))
276+
|Available fields: ${fieldNames.mkString(", ")}""".stripMargin))
277277
}
278278

279279
/**
@@ -287,7 +287,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
287287
if (nonExistFields.nonEmpty) {
288288
throw new IllegalArgumentException(
289289
s"""Nonexistent field(s): ${nonExistFields.mkString(", ")}.
290-
|Available fields: ${fieldNamesSet.mkString(", ")}""".stripMargin)
290+
|Available fields: ${fieldNames.mkString(", ")}""".stripMargin)
291291
}
292292
// Preserve the original order of fields.
293293
StructType(fields.filter(f => names.contains(f.name)))
@@ -302,7 +302,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
302302
nameToIndex.getOrElse(name,
303303
throw new IllegalArgumentException(
304304
s"""Field "$name" does not exist.
305-
|Available fields: ${fieldNamesSet.mkString(", ")}""".stripMargin))
305+
|Available fields: ${fieldNames.mkString(", ")}""".stripMargin))
306306
}
307307

308308
private[sql] def getFieldIndex(name: String): Option[Int] = {

0 commit comments

Comments
 (0)