Skip to content

Commit 3eb6fab

Browse files
authored
Fix E2E WindowSpecTests for Spark 3.0 (#354)
1 parent 486a4be commit 3eb6fab

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/Expressions/WindowSpecTests.cs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using Microsoft.Spark.Sql;
67
using Microsoft.Spark.Sql.Expressions;
78
using Xunit;
@@ -23,26 +24,36 @@ public void TestSignaturesV2_3_X()
2324
Column col2 = Column("name");
2425
WindowSpec windowSpec = PartitionBy("age");
2526

26-
windowSpec = windowSpec.PartitionBy("age");
27-
windowSpec = windowSpec.PartitionBy("age", "name");
28-
windowSpec = windowSpec.PartitionBy();
29-
windowSpec = windowSpec.PartitionBy(col1);
30-
windowSpec = windowSpec.PartitionBy(col1, col2);
27+
Assert.IsType<WindowSpec>(windowSpec.PartitionBy("age"));
28+
Assert.IsType<WindowSpec>(windowSpec.PartitionBy("age", "name"));
29+
Assert.IsType<WindowSpec>(windowSpec.PartitionBy());
30+
Assert.IsType<WindowSpec>(windowSpec.PartitionBy(col1));
31+
Assert.IsType<WindowSpec>(windowSpec.PartitionBy(col1, col2));
3132

32-
windowSpec = windowSpec.OrderBy("age");
33-
windowSpec = windowSpec.OrderBy("age", "name");
34-
windowSpec = windowSpec.OrderBy();
35-
windowSpec = windowSpec.OrderBy(col1);
36-
windowSpec = windowSpec.OrderBy(col1, col2);
33+
Assert.IsType<WindowSpec>(windowSpec.OrderBy("age"));
34+
Assert.IsType<WindowSpec>(windowSpec.OrderBy("age", "name"));
35+
Assert.IsType<WindowSpec>(windowSpec.OrderBy());
36+
Assert.IsType<WindowSpec>(windowSpec.OrderBy(col1));
37+
Assert.IsType<WindowSpec>(windowSpec.OrderBy(col1, col2));
3738

38-
windowSpec = windowSpec.RowsBetween(
39-
Sql.Expressions.Window.UnboundedPreceding,
40-
Sql.Expressions.Window.UnboundedFollowing);
39+
Assert.IsType<WindowSpec>(
40+
windowSpec.RowsBetween(
41+
Sql.Expressions.Window.UnboundedPreceding,
42+
Sql.Expressions.Window.UnboundedFollowing));
4143

42-
windowSpec = windowSpec.RangeBetween(
43-
Sql.Expressions.Window.UnboundedPreceding,
44-
Sql.Expressions.Window.UnboundedFollowing);
45-
windowSpec = windowSpec.RangeBetween(UnboundedPreceding(), UnboundedFollowing());
44+
Assert.IsType<WindowSpec>(
45+
windowSpec.RangeBetween(
46+
Sql.Expressions.Window.UnboundedPreceding,
47+
Sql.Expressions.Window.UnboundedFollowing));
48+
49+
if (SparkSettings.Version < new Version(Versions.V3_0_0))
50+
{
51+
// The following APIs are removed in Spark 3.0.
52+
Assert.IsType<WindowSpec>(
53+
windowSpec.RangeBetween(
54+
UnboundedPreceding(),
55+
UnboundedFollowing()));
56+
}
4657
}
4758
}
4859
}

src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/Expressions/WindowTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,23 @@ public void TestSignaturesV2_3_X()
3939
Assert.IsType<WindowSpec>(OrderBy(col1));
4040
Assert.IsType<WindowSpec>(OrderBy(col1, col2));
4141

42-
Assert.IsType<WindowSpec>(RowsBetween(
43-
Sql.Expressions.Window.UnboundedPreceding,
44-
Sql.Expressions.Window.UnboundedFollowing));
42+
Assert.IsType<WindowSpec>(
43+
RowsBetween(
44+
Sql.Expressions.Window.UnboundedPreceding,
45+
Sql.Expressions.Window.UnboundedFollowing));
4546

46-
Assert.IsType<WindowSpec>(RangeBetween(
47-
Sql.Expressions.Window.UnboundedPreceding,
48-
Sql.Expressions.Window.UnboundedFollowing));
47+
Assert.IsType<WindowSpec>(
48+
RangeBetween(
49+
Sql.Expressions.Window.UnboundedPreceding,
50+
Sql.Expressions.Window.UnboundedFollowing));
4951

5052
if (SparkSettings.Version < new Version(Versions.V3_0_0))
5153
{
5254
// The following APIs are removed in Spark 3.0.
53-
Assert.IsType<WindowSpec>(RangeBetween(
54-
UnboundedPreceding(),
55-
UnboundedFollowing()));
55+
Assert.IsType<WindowSpec>(
56+
RangeBetween(
57+
UnboundedPreceding(),
58+
UnboundedFollowing()));
5659
}
5760
}
5861
}

src/csharp/Microsoft.Spark/Sql/Expressions/WindowSpec.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public WindowSpec RangeBetween(long start, long end) =>
8787
/// <summary>
8888
/// Defines the frame boundaries, from `start` (inclusive) to `end` (inclusive).
8989
/// </summary>
90+
/// <remarks>
91+
/// This API is deprecated in Spark 2.4 and removed in Spark 3.0.
92+
/// </remarks>
9093
/// <param name="start">
9194
/// Boundary start, inclusive. The frame is unbounded if the expression is
9295
/// `Microsoft.Spark.Sql.Functions.UnboundedPreceding()`
@@ -96,6 +99,8 @@ public WindowSpec RangeBetween(long start, long end) =>
9699
/// `Microsoft.Spark.Sql.Functions.UnboundedFollowing()`
97100
/// </param>
98101
/// <returns>WindowSpec object</returns>
102+
[Deprecated(Versions.V2_4_0)]
103+
[Removed(Versions.V3_0_0)]
99104
public WindowSpec RangeBetween(Column start, Column end) =>
100105
WrapAsWindowSpec(_jvmObject.Invoke("rangeBetween", start, end));
101106

0 commit comments

Comments
 (0)