Method CreateStructType
- Namespace
- SparkTest.NET.Extensions
- Assembly
- SparkTest.NET.dll
CreateStructType<T>()
Creates a struct type from a given T
[Pure]
public static StructType CreateStructType<T>() where T : class
Returns
- StructType
struct type
Type Parameters
T
some T
Examples
Converting a simple POCO to a struct type
class Toy
{
public string? Name { get; set; }
public string? Brand { get; set; }
public decimal Cost { get; set; }
}
[Fact(DisplayName = "POCOs can be converted to Spark Struct types, Example 3")]
public static void Case11() =>
DataFrameExtensions
.CreateStructType<Toy>()
.Should()
.Be(
new StructType(
new[]
{
new StructField("Name", new StringType()),
new StructField("Brand", new StringType()),
new StructField("Cost", new DecimalType())
}
)
);
Exceptions
- NotSupportedException
if the type is not supported in spark