зеркало из https://github.com/dotnet/spark.git
Spark 3.1.0 APIs - Column (#887)
This commit is contained in:
Родитель
469f2607f4
Коммит
affd7f2493
|
@ -2,6 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Spark.E2ETest.Utils;
|
||||
using Microsoft.Spark.Sql;
|
||||
using Xunit;
|
||||
using static Microsoft.Spark.Sql.Expressions.Window;
|
||||
|
@ -143,5 +144,18 @@ namespace Microsoft.Spark.E2ETest.IpcTests
|
|||
Assert.Equal("col2", col2.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test signatures for APIs introduced in Spark 3.1.*.
|
||||
/// </summary>
|
||||
[SkipIfSparkVersionIsLessThan(Versions.V3_1_0)]
|
||||
public void TestSignaturesV3_1_X()
|
||||
{
|
||||
Column col = Column("col");
|
||||
|
||||
Assert.IsType<Column>(col.WithField("col2", Lit(3)));
|
||||
|
||||
Assert.IsType<Column>(col.DropFields("col"));
|
||||
Assert.IsType<Column>(col.DropFields("col", "col2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,6 +450,31 @@ namespace Microsoft.Spark.Sql
|
|||
return ApplyMethod("getItem", key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An expression that adds/replaces field in <see cref="Types.StructType"/> by name.
|
||||
/// </summary>
|
||||
/// <param name="fieldName">The name of the field</param>
|
||||
/// <param name="column">Column to assign to the field</param>
|
||||
/// <returns>
|
||||
/// New column after adding/replacing field in <see cref="Types.StructType"/> by name.
|
||||
/// </returns>
|
||||
[Since(Versions.V3_1_0)]
|
||||
public Column WithField(string fieldName, Column column)
|
||||
{
|
||||
return ApplyMethod("withField", fieldName, column);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An expression that drops fields in <see cref="Types.StructType"/> by name.
|
||||
/// </summary>
|
||||
/// <param name="fieldNames">Name of fields to drop.</param>
|
||||
/// <returns>New column after after dropping fields.</returns>
|
||||
[Since(Versions.V3_1_0)]
|
||||
public Column DropFields(params string[] fieldNames)
|
||||
{
|
||||
return ApplyMethod("dropFields", fieldNames);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An expression that gets a field by name in a `StructType`.
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче