diff --git a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/DataFrameTests.cs b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/DataFrameTests.cs index 46e899a87..c2dc897db 100644 --- a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/DataFrameTests.cs +++ b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/DataFrameTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using Apache.Arrow; using Microsoft.Data.Analysis; @@ -459,6 +460,13 @@ public void TestSignaturesV2_3_X() Assert.Equal(2, _df.Columns().ToArray().Length); + var expected = new List> + { + new Tuple("age", "integer"), + new Tuple("name", "string") + }; + Assert.Equal(expected, _df.DTypes()); + Assert.IsType(_df.IsLocal()); Assert.IsType(_df.IsStreaming()); diff --git a/src/csharp/Microsoft.Spark/Sql/DataFrame.cs b/src/csharp/Microsoft.Spark/Sql/DataFrame.cs index afb455f73..28a6f799f 100644 --- a/src/csharp/Microsoft.Spark/Sql/DataFrame.cs +++ b/src/csharp/Microsoft.Spark/Sql/DataFrame.cs @@ -84,6 +84,14 @@ public void Explain(bool extended = false) Console.WriteLine((string)execution.Invoke(extended ? "toString" : "simpleString")); } + /// + /// Returns all column names and their data types as an IEnumerable of Tuples. + /// + /// IEnumerable of Tuple of strings + public IEnumerable> DTypes() => + Schema().Fields.Select( + f => new Tuple(f.Name, f.DataType.SimpleString)); + /// /// Returns all column names. ///