Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Floor does not handle Dictionary<string, DateTime> #525

Open
Pragmateek opened this issue Jul 1, 2024 · 0 comments
Open

[BUG]: Floor does not handle Dictionary<string, DateTime> #525

Pragmateek opened this issue Jul 1, 2024 · 0 comments
Assignees
Labels
🧱 Floor Floor desktop application

Comments

@Pragmateek
Copy link

Library Version

4.24.0

OS

Windows 11

OS Architecture

64 bit

How to reproduce?

Serialize an instance of a class containing a Dictionary<string, DateTime> to Parquet using Parquet.Net 4.25.0-pre.2:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Parquet.Serialization;
using NFluent;
using NUnit.Framework;

public class TestDico
{
    public Dictionary<string, DateTime> Values { get; set; }
}

[TestFixture]
public class ParquetSerializerTest
{
    [Test]
    public async Task CanSerializeADictionary()
    {
        var filePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.parquet");

        var inputDictionary = new TestDico { Values = new Dictionary<string, DateTime> { { "Now", DateTime.UtcNow } } };
        await ParquetSerializer.SerializeAsync(new[] { inputDictionary }, filePath);

        var outputDictionary = (await ParquetSerializer.DeserializeAsync<TestDico>(filePath)).Single();

        Check.That(outputDictionary.Values.SequenceEqual(inputDictionary.Values)).Is(true);
    }
}

The roundtrip test passes.
But Floor 4.24.0 cannot open the Parquet file:
image

System.FieldAccessException: failed to compile 'Values/key_value/Value (System.DateTime)'
 ---> System.InvalidOperationException: The binary operator Equal is not defined for the types 'System.DateTime' and 'System.Object'.
   at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType, String, Expression, Expression, Boolean)
   at System.Linq.Expressions.Expression.Equal(Expression, Expression, Boolean, MethodInfo )
   at System.Linq.Expressions.Expression.Equal(Expression, Expression)
   at Parquet.Serialization.Dremel.FieldAssemblerCompiler`1.GetClassMember(Type rootType, Expression rootVar, Field parentField, Field field, String name)
   at Parquet.Serialization.Dremel.FieldAssemblerCompiler`1.InjectLevel(Expression rootVar, Type rootType, Field parentField, Field[] levelFields, List`1 path)
   at Parquet.Serialization.Dremel.FieldAssemblerCompiler`1.InjectLevel(Expression rootVar, Type rootType, Field parentField, Field[] levelFields, List`1 path)
   at Parquet.Serialization.Dremel.FieldAssemblerCompiler`1.InjectColumn()
   at Parquet.Serialization.Dremel.FieldAssemblerCompiler`1.Compile()
   at Parquet.Serialization.Dremel.Assembler`1.Compile(ParquetSchema schema, DataField df)
   --- End of inner exception stack trace ---
   at Parquet.Serialization.Dremel.Assembler`1.Compile(ParquetSchema schema, DataField df)
   at Parquet.Serialization.Dremel.Assembler`1.<>c__DisplayClass0_0.<.ctor>b__0(DataField df)
   at System.Linq.Enumerable.SelectArrayIterator`2.Fill(ReadOnlySpan`1, Span`1, Func`2)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1)
   at Parquet.Serialization.Dremel.Assembler`1..ctor(ParquetSchema schema)
   at Parquet.Serialization.ParquetSerializer.<>c__DisplayClass23_0.<GetAssembler>b__0(ParquetSchema _)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2)
   at Parquet.Serialization.ParquetSerializer.GetAssembler(ParquetSchema schema)
   at Parquet.Serialization.ParquetSerializer.DeserializeAsync(Stream source, ParquetOptions options, CancellationToken cancellationToken)
   at Parquet.Floor.ViewModels.DataViewModel.InitReaderAsync(FileViewModel file, Stream fileStream)

Failing test

No response

@aloneguid aloneguid self-assigned this Oct 2, 2024
@aloneguid aloneguid added the 🧱 Floor Floor desktop application label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧱 Floor Floor desktop application
Projects
None yet
Development

No branches or pull requests

2 participants