Skip to content

Commit

Permalink
Simplify test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Apr 12, 2017
1 parent 5362eb9 commit b97b46e
Showing 1 changed file with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -814,29 +814,16 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
assert(cast(1.0, DateType).checkInputDataTypes().isFailure)
}

test("cast with same structure") {
val from = StructType(Seq(
StructField("a",
ArrayType(StringType, containsNull = false), nullable = true),
StructField("m",
MapType(StringType, StringType, valueContainsNull = false), nullable = true),
StructField("s",
StructType(Seq(
StructField("i", IntegerType, nullable = true))))))

val to = StructType(Seq(
StructField("x",
ArrayType(StringType, containsNull = false), nullable = true),
StructField("y",
MapType(StringType, StringType, valueContainsNull = false), nullable = true),
StructField("z",
StructType(Seq(
StructField("pgit ch", IntegerType, nullable = true))))))
test("SPARK-20302 cast with same structure") {
val from = new StructType()
.add("a", IntegerType)
.add("b", new StructType().add("b1", LongType))

val input = Row(
Seq("123", "true", "f"),
Map("a" -> "123", "b" -> "true", "c" -> "f"),
Row(0))
val to = new StructType()
.add("a1", IntegerType)
.add("b1", new StructType().add("b11", LongType))

val input = Row(10, Row(12L))

checkEvaluation(cast(Literal.create(input, from), to), input)
}
Expand Down

0 comments on commit b97b46e

Please sign in to comment.