@@ -119,6 +119,23 @@ TEST_CASE_METHOD(GlobalFixture, "Test_vertices_builder") {
119119 // check the number of vertices in builder
120120 REQUIRE (builder->GetNum () == lines);
121121
122+ // add property column
123+ std::vector<std::any> int_values (builder->GetNum ());
124+ std::vector<std::any> string_values (builder->GetNum ());
125+ for (IdType i = 0 ; i < builder->GetNum (); i++) {
126+ int_values[i] = i + 10 ;
127+ string_values[i] = std::to_string (i);
128+ }
129+
130+ REQUIRE (builder->AddPropertyColumn (" id" , int_values).ok ());
131+ REQUIRE (builder->AddPropertyColumn (" firstName" , string_values).ok ());
132+
133+ int_values.push_back (100 );
134+ string_values.push_back (" test" );
135+
136+ REQUIRE (builder->AddPropertyColumn (" id" , int_values).IsInvalid ());
137+ REQUIRE (builder->AddPropertyColumn (" firstName" , string_values).IsInvalid ());
138+
122139 // dump to files
123140 REQUIRE (builder->Dump ().ok ());
124141
@@ -145,6 +162,37 @@ TEST_CASE_METHOD(GlobalFixture, "Test_vertices_builder") {
145162 auto row_group_meta = parquet_metadata->RowGroup (0 );
146163 auto col_meta = row_group_meta->ColumnChunk (0 );
147164 REQUIRE (col_meta->compression () == parquet::Compression::LZ4);
165+
166+ // check that properties were added correctly
167+ auto name_file = " /tmp/vertex/person/firstName_lastName_gender/chunk0" ;
168+
169+ std::unique_ptr<parquet::arrow::FileReader> name_reader;
170+
171+ REQUIRE (graphar::util::OpenParquetArrowReader (
172+ name_file, arrow::default_memory_pool (), &name_reader)
173+ .ok ());
174+
175+ auto id_col = parquet_table->GetColumnByName (" id" );
176+
177+ auto maybe_name_table = name_reader->ReadTable ();
178+ REQUIRE (maybe_name_table.ok ());
179+ auto name_table = maybe_name_table.ValueOrDie ();
180+ auto name_col = name_table->GetColumnByName (" firstName" );
181+
182+ REQUIRE (name_col != nullptr );
183+ REQUIRE (id_col != nullptr );
184+
185+ REQUIRE (id_col->type ()->id () == arrow::Type::INT64);
186+ auto id_array = std::static_pointer_cast<arrow::Int64Array>(id_col->chunk (0 ));
187+ auto name_array =
188+ std::static_pointer_cast<arrow::StringArray>(name_col->chunk (0 ));
189+
190+ for (IdType i = 0 ; i < id_array->length (); i++) {
191+ REQUIRE (id_array->Value (i) == i + 10 );
192+ }
193+ for (IdType i = 0 ; i < name_array->length (); i++) {
194+ REQUIRE (name_array->GetString (i) == std::to_string (i));
195+ }
148196}
149197
150198TEST_CASE_METHOD (GlobalFixture, " test_edges_builder" ) {
@@ -221,6 +269,17 @@ TEST_CASE_METHOD(GlobalFixture, "test_edges_builder") {
221269 // check the number of edges in builder
222270 REQUIRE (builder->GetNum () == lines);
223271
272+ // add property column
273+ std::vector<std::any> string_values (builder->GetNum (),
274+ std::string (" test_edge" ));
275+
276+ REQUIRE (builder->AddPropertyColumn (" creationDate" , string_values).ok ());
277+
278+ string_values.push_back (std::string (" test" ));
279+
280+ REQUIRE (
281+ builder->AddPropertyColumn (" creationDate" , string_values).IsInvalid ());
282+
224283 // dump to files
225284 REQUIRE (builder->Dump ().ok ());
226285
@@ -251,5 +310,17 @@ TEST_CASE_METHOD(GlobalFixture, "test_edges_builder") {
251310 auto row_group_meta = parquet_metadata->RowGroup (0 );
252311 auto col_meta = row_group_meta->ColumnChunk (0 );
253312 REQUIRE (col_meta->compression () == parquet::Compression::LZ4);
313+ // check that properties were added correctly
314+
315+ auto date_col = parquet_table->GetColumnByName (" creationDate" );
316+
317+ REQUIRE (date_col != nullptr );
318+
319+ auto string_array =
320+ std::static_pointer_cast<arrow::StringArray>(date_col->chunk (0 ));
321+
322+ for (IdType i = 0 ; i < string_array->length (); i++) {
323+ REQUIRE (string_array->GetString (i) == " test_edge" );
324+ }
254325}
255326} // namespace graphar
0 commit comments