File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Microsoft.Spark.E2ETest/IpcTests/Sql Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 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 ;
56using Microsoft . Spark . Sql ;
67using Xunit ;
78using 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}
Original file line number Diff line number Diff 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">Column to assign to the field</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>
You can’t perform that action at this time.
0 commit comments