Skip to content

Commit 997b2b1

Browse files
committed
initial commit
1 parent 3fb684c commit 997b2b1

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/ColumnTests.cs

+14
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 Microsoft.Spark.E2ETest.Utils;
56
using Microsoft.Spark.Sql;
67
using Xunit;
78
using static Microsoft.Spark.Sql.Expressions.Window;
@@ -143,5 +144,18 @@ public void TestSignaturesV2_3_X()
143144
Assert.Equal("col2", col2.ToString());
144145
}
145146

147+
/// <summary>
148+
/// Test signatures for APIs introduced in Spark 3.1.*.
149+
/// </summary>
150+
[SkipIfSparkVersionIsLessThan(Versions.V3_1_0)]
151+
public void TestSignaturesV3_1_X()
152+
{
153+
Column col = Column("col");
154+
155+
Assert.IsType<Column>(col.WithField("col2", Lit(3)));
156+
157+
Assert.IsType<Column>(col.DropFields("col"));
158+
Assert.IsType<Column>(col.DropFields("col", "col2"));
159+
}
146160
}
147161
}

src/csharp/Microsoft.Spark/Sql/Column.cs

+25
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,31 @@ public Column GetItem(object key)
450450
return ApplyMethod("getItem", key);
451451
}
452452

453+
/// <summary>
454+
/// An expression that adds/replaces field in <see cref="Types.StructType"/> by name.
455+
/// </summary>
456+
/// <param name="fieldName">The name of the field</param>
457+
/// <param name="column"></param>
458+
/// <returns>
459+
/// New column after adding/replacing field in <see cref="Types.StructType"/> by name.
460+
/// </returns>
461+
[Since(Versions.V3_1_0)]
462+
public Column WithField(string fieldName, Column column)
463+
{
464+
return ApplyMethod("withField", fieldName, column);
465+
}
466+
467+
/// <summary>
468+
/// An expression that drops fields in <see cref="Types.StructType"/> by name.
469+
/// </summary>
470+
/// <param name="fieldNames">Name of fields to drop.</param>
471+
/// <returns>New column after after dropping fields.</returns>
472+
[Since(Versions.V3_1_0)]
473+
public Column DropFields(params string[] fieldNames)
474+
{
475+
return ApplyMethod("dropFields", fieldNames);
476+
}
477+
453478
/// <summary>
454479
/// An expression that gets a field by name in a `StructType`.
455480
/// </summary>

src/csharp/Microsoft.Spark/Versions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ internal static class Versions
1313
internal const string V2_4_0 = "2.4.0";
1414
internal const string V2_4_2 = "2.4.2";
1515
internal const string V3_0_0 = "3.0.0";
16+
internal const string V3_1_0 = "3.1.0";
1617
internal const string V3_1_1 = "3.1.1";
1718
}
1819
}

0 commit comments

Comments
 (0)