Skip to content

Commit

Permalink
update test to remove timestamp string
Browse files Browse the repository at this point in the history
  • Loading branch information
suhsteve committed Mar 27, 2021
1 parent 487e729 commit 9fb90c3
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,12 @@ public void TestUdfWithDuplicateTimestamps()
};

var expectedTimestamp = new Timestamp(1970, 1, 2, 0, 0, 0, 0);
string tsString = expectedTimestamp.ToString();
var returnType = new StructType(new[] { new StructField("tsString", new StringType()) });
Func<Column, Column> udf =
Udf<Row>(row => new GenericRow(new string[] { tsString }), returnType);
Func<Column, Column> udf = Udf<Timestamp, Timestamp>(
ts => new Timestamp(1970, 1, 2, 0, 0, 0, 0));

DataFrame df = _spark.CreateDataFrame(data, schema);
Column newCol = udf(Struct(df.Col("ts")))
.GetField("tsString")
.Cast("timestamp")
.Alias("tsStringCastToTs");

Row[] rows = df.Select(newCol).Collect().ToArray();
Row[] rows = df.Select(udf(df["ts"])).Collect().ToArray();

Assert.Equal(3, rows.Length);
foreach (Row row in rows)
Expand Down

0 comments on commit 9fb90c3

Please sign in to comment.