File tree 3 files changed +40
-0
lines changed
Microsoft.Spark.E2ETest/IpcTests/Sql
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using Microsoft . Spark . E2ETest . Utils ;
5
6
using Microsoft . Spark . Sql ;
6
7
using Xunit ;
7
8
using static Microsoft . Spark . Sql . Expressions . Window ;
@@ -143,5 +144,18 @@ public void TestSignaturesV2_3_X()
143
144
Assert . Equal ( "col2" , col2 . ToString ( ) ) ;
144
145
}
145
146
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
+ }
146
160
}
147
161
}
Original file line number Diff line number Diff line change @@ -450,6 +450,31 @@ public Column GetItem(object key)
450
450
return ApplyMethod ( "getItem" , key ) ;
451
451
}
452
452
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
+
453
478
/// <summary>
454
479
/// An expression that gets a field by name in a `StructType`.
455
480
/// </summary>
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ internal static class Versions
13
13
internal const string V2_4_0 = "2.4.0" ;
14
14
internal const string V2_4_2 = "2.4.2" ;
15
15
internal const string V3_0_0 = "3.0.0" ;
16
+ internal const string V3_1_0 = "3.1.0" ;
16
17
internal const string V3_1_1 = "3.1.1" ;
17
18
}
18
19
}
You can’t perform that action at this time.
0 commit comments