parquet-dotnet icon indicating copy to clipboard operation
parquet-dotnet copied to clipboard

Serialization of interface typed members

Open Pragmateek opened this issue 8 months ago • 6 comments

Issue description

Hello,

Is there a way to serialize types whose any member is interface typed? I get a NotImplementedException in MakeField.

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 is there a way to force the serialization?

Thanks in advance,

Mickael

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();
}

Pragmateek avatar May 30 '24 09:05 Pragmateek