Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0366e11
Add .NET formatting workflow and minor code cleanup
sheddy123 Aug 3, 2026
cbea28c
Add DataFrame union example and improve code formatting
sheddy123 Aug 3, 2026
c3f646f
Add blank line for readability in VectorFunctions.intrinsics.cs
sheddy123 Aug 3, 2026
b7e96d4
Clean up and reorder using directives in ML.Feature
sheddy123 Aug 3, 2026
4bff1b8
Refactor: remove line breaks in Avro function signatures
sheddy123 Aug 3, 2026
ade4135
Refactor formatting in Trigger.cs and ComplexTypes.cs
sheddy123 Aug 3, 2026
c3ed31a
Add XML documentation to Microsoft.Spark.Sql classes
sheddy123 Aug 3, 2026
5d8cc5d
Improve formatting and whitespace in ML feature tests
sheddy123 Aug 3, 2026
eafeee0
Code formatting and minor structural improvements
sheddy123 Aug 3, 2026
57c19c4
Refactor unit tests and add MapType/StructType coverage
sheddy123 Aug 3, 2026
b2a3e3f
Add test for JvmCallbackClient and code formatting fixes
sheddy123 Aug 3, 2026
0573abd
Add SparkSession.Active() test and reorder using directive
sheddy123 Aug 3, 2026
58f8747
Format cleanup in ParamTests.cs Test() method
sheddy123 Aug 3, 2026
8f848b9
Reorganize usings and minor formatting cleanup
sheddy123 Aug 3, 2026
ecf4618
Set default Spark log level to ERROR in tests
sheddy123 Aug 3, 2026
9fc8bfb
Reorder using directives for clarity and style
sheddy123 Aug 3, 2026
574b09a
Add XML docs, refactor if, and add JVM callback client
sheddy123 Aug 3, 2026
069232f
Reorder using directives in ConfigurationService.cs
sheddy123 Aug 3, 2026
4dd3d5e
Add XML docs to Param class for improved clarity
sheddy123 Aug 3, 2026
f25a8ed
Minor formatting cleanup in Broadcast.cs and JvmException.cs
sheddy123 Aug 3, 2026
66c53bf
Simulate multiple assemblies in package resolver test
sheddy123 Aug 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check formatting

on:
pull_request:
push:
branches: [ main ]

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json

- name: Verify code formatting
run: |
dotnet format src/csharp/Microsoft.Spark.sln --verify-no-changes
dotnet format examples/Microsoft.Spark.Examples.sln --verify-no-changes
dotnet format benchmark/csharp/Microsoft.Spark.Benchmark.sln --verify-no-changes
2 changes: 1 addition & 1 deletion benchmark/csharp/Tpch/VectorFunctions.intrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal static unsafe DoubleArray ComputeDiscountPrice(DoubleArray price, Doubl
fixed (double* pBuffer = buffer)
{
Vector256<double> ones = Vector256.Create(1.0);

int i = 0;
for (; i < vectorizationLength; i += 4)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Run(string[] args)

DataFrame joinedDf3 = df.Join(df, df["name"] == df["name"], "outer");
joinedDf3.Show();

// Union of two data frames
DataFrame unionDf = df.Union(df);
unionDf.Show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Run(string[] args)
{
Console.Error.WriteLine(
"Usage: Datasource <path to SPARK_HOME/examples/src/main/resources/>");

Environment.Exit(1);
}

Expand Down Expand Up @@ -92,11 +92,11 @@ private void RunDatasourceExample(SparkSession spark)
private void RunParquetExample(SparkSession spark, string json)
{
DataFrame peopleDf = spark.Read().Json(json);

peopleDf.Write().Mode(SaveMode.Overwrite).Parquet("people.parquet");

DataFrame parquetFile = spark.Read().Parquet("people.parquet");

parquetFile.CreateTempView("parquet");

DataFrame teenagers = spark.Sql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Run(string[] args)
.WriteStream()
.Format("console")
.Start();

query.AwaitTermination();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void TestPackageResolver()
using (File.Create(nugetFile.FullName))
{
}

var assemblyPaths = new string[]
{
Path.Combine(packageFrameworkPath, "1.dll"),
Expand All @@ -51,7 +51,7 @@ public void TestPackageResolver()
packageVersion,
assemblyPaths,
packageRootPath,
probingPaths)
probingPaths)
});

var packageResolver = new PackageResolver(mockSupportNugetWrapper.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ public void TestBucketizer()
Assert.Equal(expectedInputCol, bucketizer.GetInputCol());
Assert.Equal(expectedOutputCol, bucketizer.GetOutputCol());
Assert.Equal(expectedSplits, bucketizer.GetSplits());

using (var tempDirectory = new TemporaryDirectory())
{
string savePath = Path.Join(tempDirectory.Path, "bucket");
bucketizer.Save(savePath);

Bucketizer loadedBucketizer = Bucketizer.Load(savePath);
Assert.Equal(bucketizer.Uid(), loadedBucketizer.Uid());
}

TestFeatureBase(bucketizer, "handleInvalid", "keep");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public void TestCountVectorizerModel()
{
DataFrame input = _spark.Sql("SELECT array('hello', 'I', 'AM', 'a', 'string', 'TO', " +
"'TOKENIZE') as input from range(100)");

const string inputColumn = "input";
const string outputColumn = "output";
const double minTf = 10.0;
const bool binary = false;

var vocabulary = new List<string>()
{
"hello",
Expand All @@ -45,17 +45,17 @@ public void TestCountVectorizerModel()
"TO",
"TOKENIZE"
};

var countVectorizerModel = new CountVectorizerModel(vocabulary);

Assert.IsType<CountVectorizerModel>(new CountVectorizerModel("my-uid", vocabulary));

countVectorizerModel = countVectorizerModel
.SetInputCol(inputColumn)
.SetOutputCol(outputColumn)
.SetMinTF(minTf)
.SetBinary(binary);

Assert.Equal(inputColumn, countVectorizerModel.GetInputCol());
Assert.Equal(outputColumn, countVectorizerModel.GetOutputCol());
Assert.Equal(minTf, countVectorizerModel.GetMinTF());
Expand All @@ -64,7 +64,7 @@ public void TestCountVectorizerModel()
{
string savePath = Path.Join(tempDirectory.Path, "countVectorizerModel");
countVectorizerModel.Save(savePath);

CountVectorizerModel loadedModel = CountVectorizerModel.Load(savePath);
Assert.Equal(countVectorizerModel.Uid(), loadedModel.Uid());
}
Expand All @@ -75,8 +75,8 @@ public void TestCountVectorizerModel()

Assert.IsType<StructType>(countVectorizerModel.TransformSchema(input.Schema()));
Assert.IsType<DataFrame>(countVectorizerModel.Transform(input));

TestFeatureBase(countVectorizerModel, "minDF", 100);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public void TestCountVectorizer()
const double minTf = 10;
const int vocabSize = 10000;
const bool binary = false;

var countVectorizer = new CountVectorizer();

countVectorizer
.SetInputCol(inputColumn)
.SetOutputCol(outputColumn)
.SetMinDF(minDf)
.SetMinTF(minTf)
.SetVocabSize(vocabSize);

Assert.IsType<CountVectorizerModel>(countVectorizer.Fit(input));
Assert.Equal(inputColumn, countVectorizer.GetInputCol());
Assert.Equal(outputColumn, countVectorizer.GetOutputCol());
Expand All @@ -60,17 +60,17 @@ public void TestCountVectorizer()
{
string savePath = Path.Join(tempDirectory.Path, "countVectorizer");
countVectorizer.Save(savePath);

CountVectorizer loadedVectorizer = CountVectorizer.Load(savePath);
Assert.Equal(countVectorizer.Uid(), loadedVectorizer.Uid());
}

Assert.NotEmpty(countVectorizer.ExplainParams());
Assert.NotEmpty(countVectorizer.ToString());

TestFeatureBase(countVectorizer, "minDF", 0.4);
}

/// <summary>
/// Test signatures for APIs introduced in Spark 2.4.*.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ protected FeatureBaseTests(SparkFixture fixture)
{
_spark = fixture.Spark;
}

/// <summary>
/// Tests the common functionality across all ML.Feature classes.
/// </summary>
/// <param name="testObject">The object that implemented FeatureBase</param>
/// <param name="paramName">The name of a parameter that can be set on this object</param>
/// <param name="paramValue">A parameter value that can be set on this object</param>
public void TestFeatureBase(
Params testObject,
string paramName,
Params testObject,
string paramName,
object paramValue)
{
Assert.NotEmpty(testObject.ExplainParams());

Param param = testObject.GetParam(paramName);
Assert.NotEmpty(param.Doc);
Assert.NotEmpty(param.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void TestHashingTF()
int expectedFeatures = 10;

Assert.IsType<HashingTF>(new HashingTF());

HashingTF hashingTf = new HashingTF("my-unique-id")
.SetNumFeatures(expectedFeatures)
.SetInputCol(expectedInputCol)
Expand All @@ -43,21 +43,21 @@ public void TestHashingTF()

DataFrame output = hashingTf.Transform(input);
DataFrame outputVector = output.Select(expectedOutputCol);

Assert.Contains(expectedOutputCol, outputVector.Columns());

using (var tempDirectory = new TemporaryDirectory())
{
string savePath = Path.Join(tempDirectory.Path, "hashingTF");
hashingTf.Save(savePath);

HashingTF loadedHashingTf = HashingTF.Load(savePath);
Assert.Equal(hashingTf.Uid(), loadedHashingTf.Uid());
}

hashingTf.SetBinary(true);
Assert.True(hashingTf.GetBinary());

TestFeatureBase(hashingTf, "numFeatures", 1000);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public void TestIDFModel()
int expectedDocFrequency = 1980;
string expectedInputCol = "rawFeatures";
string expectedOutputCol = "features";

DataFrame sentenceData =
_spark.Sql("SELECT 0.0 as label, 'Hi I heard about Spark' as sentence");

Tokenizer tokenizer = new Tokenizer()
.SetInputCol("sentence")
.SetOutputCol("words");

DataFrame wordsData = tokenizer.Transform(sentenceData);

HashingTF hashingTF = new HashingTF()
Expand All @@ -42,21 +42,21 @@ public void TestIDFModel()
.SetNumFeatures(20);

DataFrame featurizedData = hashingTF.Transform(wordsData);

IDF idf = new IDF()
.SetInputCol(expectedInputCol)
.SetOutputCol(expectedOutputCol)
.SetMinDocFreq(expectedDocFrequency);

IDFModel idfModel = idf.Fit(featurizedData);

DataFrame rescaledData = idfModel.Transform(featurizedData);
Assert.Contains(expectedOutputCol, rescaledData.Columns());

Assert.Equal(expectedInputCol, idfModel.GetInputCol());
Assert.Equal(expectedOutputCol, idfModel.GetOutputCol());
Assert.Equal(expectedDocFrequency, idfModel.GetMinDocFreq());

using (var tempDirectory = new TemporaryDirectory())
{
string modelPath = Path.Join(tempDirectory.Path, "idfModel");
Expand All @@ -65,7 +65,7 @@ public void TestIDFModel()
IDFModel loadedModel = IDFModel.Load(modelPath);
Assert.Equal(idfModel.Uid(), loadedModel.Uid());
}

TestFeatureBase(idfModel, "minDocFreq", 1000);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ public void TestIDFModel()
string expectedInputCol = "rawFeatures";
string expectedOutputCol = "features";
int expectedDocFrequency = 100;

IDF idf = new IDF()
.SetInputCol(expectedInputCol)
.SetOutputCol(expectedOutputCol)
.SetMinDocFreq(expectedDocFrequency);

Assert.Equal(expectedInputCol, idf.GetInputCol());
Assert.Equal(expectedOutputCol, idf.GetOutputCol());
Assert.Equal(expectedDocFrequency, idf.GetMinDocFreq());

using (var tempDirectory = new TemporaryDirectory())
{
string savePath = Path.Join(tempDirectory.Path, "IDF");
idf.Save(savePath);

IDF loadedIdf = IDF.Load(savePath);
Assert.Equal(idf.Uid(), loadedIdf.Uid());
}

TestFeatureBase(idf, "minDocFreq", 1000);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.IO;
using Microsoft.Spark.ML.Feature;
using Microsoft.Spark.Sql;
using Microsoft.Spark.UnitTest.TestUtils;
using Microsoft.Spark.Sql.Types;
using Microsoft.Spark.UnitTest.TestUtils;
using Xunit;

namespace Microsoft.Spark.E2ETest.IpcTests.ML.Feature
Expand Down Expand Up @@ -59,7 +59,7 @@ public void TestPipelineModelTransform()

Assert.IsType<StructType>(pipelineModel.TransformSchema(input.Schema()));
Assert.IsType<DataFrame>(output);

using (var tempDirectory = new TemporaryDirectory())
{
string savePath = Path.Join(tempDirectory.Path, "pipelineModel");
Expand Down
Loading