With Parquet.net, is there a way to serialize types whose any member is interface typed?
I get a NotImplementedException
in MakeField
.
using Parquet.Serialization;
//using MemoryStream stream = new();
//await ParquetSerializer.SerializeAsync([new LineOK ()], stream);
using MemoryStream stream = new();
await ParquetSerializer.SerializeAsync([new LineKO()], stream);
interface IPoint
{
decimal X { get; set; }
decimal Y { get; set; }
}
class Point : IPoint
{
public decimal X { get; set; }
public decimal Y { get; set; }
}
class LineOK
{
public Point Start { get; } = new();
public Point End { get; } = new();
}
class LineKO
{
public IPoint Start { get; } = new Point();
public IPoint End { get; } = new Point();
}
I think I understand the logical issue: in a set of objects we could have different implementations hence Parquet columns/schemas.
But in the case there is a single implementation in the dataset is there a way to force the serialization?
Otherwise what are my options?
Maybe a dedicated DTO:
using MemoryStream stream = new();
await ParquetSerializer.SerializeAsync([new LineDto(new LineKO())], stream);
class LineDto
{
public Point Start { get; }
public Point End { get; }
public LineDto(LineKO lineKo)
{
Start = (Point)lineKo.Start;
End = (Point)lineKo.End;
}
}