public void TestOptions() { // arrange mockDataFrameReaderProxy.Setup(m => m.Options(It.IsAny <Dictionary <string, string> >())); var dataFrameReader = new DataFrameReader(mockDataFrameReaderProxy.Object, sparkContext); const string key1 = "key1"; const string value1 = "value1"; const string key2 = "key2"; const string value2 = "value2"; var opts = new Dictionary <string, string>() { { key1, value1 }, { key2, value2 } }; // Act dataFrameReader.Options(opts); // Assert mockDataFrameReaderProxy.Verify(m => m.Options(It.Is <Dictionary <string, string> >( dict => dict[key1] == value1 && dict[key2] == value2 && dict.Count == 2) ), Times.Once ); }
public void TestSignaturesV2_3_X() { DataFrameReader dfr = _spark.Read(); Assert.IsType <DataFrameReader>(dfr.Format("json")); Assert.IsType <DataFrameReader>( dfr.Schema( new StructType(new[] { new StructField("age", new IntegerType()), new StructField("name", new StringType()) }))); Assert.IsType <DataFrameReader>(dfr.Schema("age INT, name STRING")); Assert.IsType <DataFrameReader>(dfr.Option("stringOption", "value")); Assert.IsType <DataFrameReader>(dfr.Option("boolOption", true)); Assert.IsType <DataFrameReader>(dfr.Option("longOption", 1L)); Assert.IsType <DataFrameReader>(dfr.Option("doubleOption", 3D)); Assert.IsType <DataFrameReader>( dfr.Options( new Dictionary <string, string> { { "option1", "value1" }, { "option2", "value2" } })); string jsonFile = $"{TestEnvironment.ResourceDirectory}people.json"; Assert.IsType <DataFrame>(dfr.Load()); Assert.IsType <DataFrame>(dfr.Load(jsonFile)); Assert.IsType <DataFrame>(dfr.Load(jsonFile, jsonFile)); Assert.IsType <DataFrame>(dfr.Json(jsonFile)); Assert.IsType <DataFrame>(dfr.Json(jsonFile, jsonFile)); string csvFile = $"{TestEnvironment.ResourceDirectory}people.csv"; Assert.IsType <DataFrame>(dfr.Csv(csvFile)); Assert.IsType <DataFrame>(dfr.Csv(csvFile, csvFile)); string parquetFile = $"{TestEnvironment.ResourceDirectory}users.parquet"; Assert.IsType <DataFrame>(dfr.Parquet(parquetFile)); Assert.IsType <DataFrame>(dfr.Parquet(parquetFile, parquetFile)); string orcFile = $"{TestEnvironment.ResourceDirectory}users.orc"; Assert.IsType <DataFrame>(dfr.Orc(orcFile)); Assert.IsType <DataFrame>(dfr.Orc(orcFile, orcFile)); dfr = _spark.Read(); string textFile = $"{TestEnvironment.ResourceDirectory}people.txt"; Assert.IsType <DataFrame>(dfr.Text(textFile)); Assert.IsType <DataFrame>(dfr.Text(textFile, textFile)); }