Skip to content

Commit 7e5a322

Browse files
committed
do not output metadata in StructField.toString
1 parent c41a664 commit 7e5a322

File tree

1 file changed

+8
-5
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ object DataType extends RegexParsers {
5757

5858
protected lazy val structField: Parser[StructField] =
5959
("StructField(" ~> "[a-zA-Z0-9_]*".r) ~ ("," ~> dataType) ~ ("," ~> boolVal <~ ")") ^^ {
60-
case name ~ tpe ~ nullable =>
61-
// TODO: parse metadata
62-
StructField(name, tpe, nullable = nullable, Map.empty)
60+
// metadata is not included in StructField.toString
61+
case name ~ tpe ~ nullable => StructField(name, tpe, nullable = nullable, Map.empty)
6362
}
6463

6564
protected lazy val boolVal: Parser[Boolean] =
@@ -336,6 +335,11 @@ case class StructField(
336335
builder.append(s"${prefix}-- ${name}: ${dataType.simpleString} (nullable = ${nullable})\n")
337336
DataType.buildFormattedString(dataType, s"$prefix |", builder)
338337
}
338+
339+
override def toString: String = {
340+
// TODO: Remove this function after SPARK-3713.
341+
s"StructField($name,$dataType,$nullable)"
342+
}
339343
}
340344

341345
object StructType {
@@ -356,8 +360,7 @@ case class StructType(fields: Seq[StructField]) extends DataType {
356360
* have a name matching the given name, `null` will be returned.
357361
*/
358362
def apply(name: String): StructField = {
359-
nameToField.getOrElse(name,
360-
throw new IllegalArgumentException(s"Field $name does not exist."))
363+
nameToField.getOrElse(name, throw new IllegalArgumentException(s"Field $name does not exist."))
361364
}
362365

363366
/**

0 commit comments

Comments
 (0)