Skip to content

Commit

Permalink
make tests work in scala
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Oct 9, 2014
1 parent 61b8e0f commit 618e349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ object DataType {

private def parseStructField(json: JValue): StructField = json match {
case JSortedObject(
("metadata", metadata: JObject),
("name", JString(name)),
("nullable", JBool(nullable)),
("type", dataType: JValue)) =>
StructField(name, parseDataType(dataType), nullable)
StructField(name, parseDataType(dataType), nullable, metadata.values)
}

@deprecated("Use DataType.fromJson instead")
Expand Down Expand Up @@ -393,14 +394,15 @@ case class StructField(
}

override def toString: String = {
// TODO: Remove this function after SPARK-3713.
// Do not add metadata to be consistent with CaseClassStringParser.
s"StructField($name,$dataType,$nullable)"
}

private[sql] def jsonValue: JValue = {
("name" -> name) ~
("type" -> dataType.jsonValue) ~
("nullable" -> nullable)
("nullable" -> nullable) ~
("metadata" -> Extraction.decompose(metadata)(DefaultFormats))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ class DataTypeSuite extends FunSuite {
checkDataTypeJsonRepr(
StructType(Seq(
StructField("a", IntegerType, nullable = true),
StructField("b", ArrayType(DoubleType), nullable = false))))
StructField("b", ArrayType(DoubleType), nullable = false),
StructField("c", DoubleType, nullable = false, metadata = Map("name" -> "age")))))
}

0 comments on commit 618e349

Please sign in to comment.