Skip to content

Commit 309f410

Browse files
authored
Revert "Add 'Z' to the string format in Timestamp.ToString() to indicate UTC time. (#871)" (#873)
This reverts commit 53717b4.
1 parent 32789e0 commit 309f410

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

azure-pipelines.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,20 @@ variables:
1616
backwardCompatibleRelease: '1.0.0'
1717
forwardCompatibleRelease: '1.0.0'
1818

19-
# Filter UdfSimpleTypesTests.TestUdfWithReturnAsTimestampType and UdfSimpleTypesTests.TestUdfWithTimestampType
20-
# backward and forward compatibility tests due to bug with Timestamp.ToString(). This is not a breaking change.
21-
# Please see https://github.com/dotnet/spark/pull/871
22-
backwardCompatibleTestOptions_Windows_2_3: "--filter \
23-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithReturnAsTimestampType)&\
24-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithTimestampType)"
25-
forwardCompatibleTestOptions_Windows_2_3: $(backwardCompatibleTestOptions_Windows_2_3)
26-
backwardCompatibleTestOptions_Linux_2_3: $(backwardCompatibleTestOptions_Windows_2_3)
27-
forwardCompatibleTestOptions_Linux_2_3: $(backwardCompatibleTestOptions_Windows_2_3)
28-
29-
backwardCompatibleTestOptions_Windows_2_4: $(backwardCompatibleTestOptions_Windows_2_3)
30-
forwardCompatibleTestOptions_Windows_2_4: $(backwardCompatibleTestOptions_Windows_2_3)
31-
backwardCompatibleTestOptions_Linux_2_4: $(backwardCompatibleTestOptions_Windows_2_3)
19+
backwardCompatibleTestOptions_Windows_2_3: ""
20+
forwardCompatibleTestOptions_Windows_2_3: ""
21+
backwardCompatibleTestOptions_Linux_2_3: ""
22+
forwardCompatibleTestOptions_Linux_2_3: ""
23+
24+
backwardCompatibleTestOptions_Windows_2_4: ""
25+
forwardCompatibleTestOptions_Windows_2_4: ""
26+
backwardCompatibleTestOptions_Linux_2_4: ""
3227
# Filter HyperspaceTests not due to functionality changes, but to incompatible tests running on Linux.
3328
# Please see https://github.com/dotnet/spark/pull/737 for the fix.
3429
forwardCompatibleTestOptions_Linux_2_4: "--filter \
3530
(FullyQualifiedName!=Microsoft.Spark.Extensions.Hyperspace.E2ETest.HyperspaceTests.TestExplainAPI)&\
3631
(FullyQualifiedName!=Microsoft.Spark.Extensions.Hyperspace.E2ETest.HyperspaceTests.TestIndexCreateAndDelete)&\
37-
(FullyQualifiedName!=Microsoft.Spark.Extensions.Hyperspace.E2ETest.HyperspaceTests.TestSignatures&\
38-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithReturnAsTimestampType)&\
39-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithTimestampType)"
32+
(FullyQualifiedName!=Microsoft.Spark.Extensions.Hyperspace.E2ETest.HyperspaceTests.TestSignatures)"
4033

4134
# Filter DataFrameTests.TestDataFrameGroupedMapUdf and DataFrameTests.TestGroupedMapUdf backwardCompatible
4235
# tests due to https://github.com/dotnet/spark/pull/711
@@ -45,10 +38,8 @@ variables:
4538
backwardCompatibleTestOptions_Windows_3_0: "--filter \
4639
(FullyQualifiedName!=Microsoft.Spark.E2ETest.IpcTests.DataFrameTests.TestDataFrameGroupedMapUdf)&\
4740
(FullyQualifiedName!=Microsoft.Spark.E2ETest.IpcTests.DataFrameTests.TestGroupedMapUdf)&\
48-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithDuplicateTimestamps)&\
49-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithReturnAsTimestampType)&\
50-
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithTimestampType)"
51-
forwardCompatibleTestOptions_Windows_3_0: $(backwardCompatibleTestOptions_Windows_2_3)
41+
(FullyQualifiedName!=Microsoft.Spark.E2ETest.UdfTests.UdfSimpleTypesTests.TestUdfWithDuplicateTimestamps)"
42+
forwardCompatibleTestOptions_Windows_3_0: ""
5243
backwardCompatibleTestOptions_Linux_3_0: $(backwardCompatibleTestOptions_Windows_3_0)
5344
forwardCompatibleTestOptions_Linux_3_0: $(forwardCompatibleTestOptions_Linux_2_4)
5445

src/csharp/Microsoft.Spark.E2ETest/UdfTests/UdfSimpleTypesTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public void TestUdfWithTimestampType()
118118

119119
var expected = new string[]
120120
{
121-
"2020-01-01 00:00:00.000000Z",
122-
"2020-01-02 15:30:30.123456Z"
121+
"2020-01-01 00:00:00.000000",
122+
"2020-01-02 15:30:30.123456"
123123
};
124124
string[] rowsToArray = rows.Select(x => x[0].ToString()).ToArray();
125125
Assert.Equal(expected, rowsToArray);
@@ -193,8 +193,8 @@ public void TestUdfWithReturnAsTimestampType()
193193

194194
var expected = new string[]
195195
{
196-
"2020-01-04 15:30:30.123456Z",
197-
"2050-01-04 15:30:30.123456Z"
196+
"2020-01-04 15:30:30.123456",
197+
"2050-01-04 15:30:30.123456"
198198
};
199199
for (int i = 0; i < rows.Length; ++i)
200200
{

src/csharp/Microsoft.Spark.UnitTest/Sql/TimestampTests.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void TimestampTest()
2929
Assert.Equal(DateTimeKind.Utc, timestamp.ToDateTime().Kind);
3030

3131
// Validate ToString().
32-
Assert.Equal("2020-01-01 08:30:30.000123Z", timestamp.ToString());
32+
Assert.Equal("2020-01-01 08:30:30.000123", timestamp.ToString());
3333

3434
// Validate ToDateTime().
3535
Assert.Equal(testDate, timestamp.ToDateTime());
@@ -57,7 +57,7 @@ public void TimestampTest()
5757
Assert.Equal(DateTimeKind.Utc, timestamp.ToDateTime().Kind);
5858

5959
// Validate ToString().
60-
Assert.Equal("2020-01-02 15:30:30.123456Z", timestamp.ToString());
60+
Assert.Equal("2020-01-02 15:30:30.123456", timestamp.ToString());
6161

6262
// Validate ToDateTime().
6363
Assert.Equal(
@@ -71,14 +71,5 @@ public void TimestampTest()
7171
() => new Timestamp(2020, 1, 2, 15, 30, 30, 1234567));
7272
}
7373
}
74-
75-
[Fact]
76-
public void TestTimestampToString()
77-
{
78-
var dateTimeObj = new DateTime(2021, 01, 01);
79-
Assert.Equal(
80-
new Timestamp(DateTime.Parse(new Timestamp(dateTimeObj).ToString())),
81-
new Timestamp(dateTimeObj));
82-
}
8374
}
8475
}

src/csharp/Microsoft.Spark/Sql/Types/Timestamp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Timestamp(
9494
/// <summary>
9595
/// Readable string representation for this type.
9696
/// </summary>
97-
public override string ToString() => _dateTime.ToString("yyyy-MM-dd HH:mm:ss.ffffffZ");
97+
public override string ToString() => _dateTime.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
9898

9999
/// <summary>
100100
/// Checks if the given object is same as the current object.

0 commit comments

Comments
 (0)