Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 4d65464

Browse files
author
Ivan Gavryliuk
committed
read and write simple maps with parquet.net
1 parent 62c0367 commit 4d65464

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Parquet.Test/MapsTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Parquet.Test
88
{
99
public class MapsTest
1010
{
11-
//[Fact]
11+
[Fact]
1212
public void Simple_first_level_map_int_to_string()
1313
{
1414
var ds = new DataSet(
@@ -24,6 +24,8 @@ public void Simple_first_level_map_int_to_string()
2424
//ParquetWriter.WriteFile(ds, "c:\\tmp\\map.parquet");
2525

2626
DataSet ds1 = DataSetGenerator.WriteRead(ds);
27+
28+
Assert.Equal("{1;[1=>one;2=>two]}", ds1[0].ToString());
2729
}
2830
}
2931
}

src/Parquet/Data/Schema/SchemaElement.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ public SchemaElement(string name, Type elementType) : this()
109109
}
110110

111111
UpdateFlags();
112+
113+
//hack: to be gone in vNext
114+
if(IsMap)
115+
{
116+
SchemaElement sKey = _extra[0];
117+
SchemaElement sValue = _extra[1];
118+
119+
sKey.MaxRepetitionLevel = MaxRepetitionLevel;
120+
sValue.MaxRepetitionLevel = MaxRepetitionLevel;
121+
122+
sKey.MaxDefinitionLevel += (MaxDefinitionLevel + 1);
123+
sValue.MaxDefinitionLevel += (MaxDefinitionLevel + 1);
124+
}
112125
}
113126

114127
internal SchemaElement(Thrift.SchemaElement tse, string nameOverride,

0 commit comments

Comments
 (0)