diff --git a/src/core/functions/scalar/weakly_connected_component.cpp b/src/core/functions/scalar/weakly_connected_component.cpp index bc877230..f0abd6fa 100644 --- a/src/core/functions/scalar/weakly_connected_component.cpp +++ b/src/core/functions/scalar/weakly_connected_component.cpp @@ -182,12 +182,16 @@ static void WeaklyConnectedComponentFunction(DataChunk &args, if (!vdata_src.validity.RowIsValid(src_pos)) { result_validity.SetInvalid(i); } else { + auto component_id = info.componentId[src_data[src_pos]]; + if (component_id == -1) { + info.componentId[src_data[src_pos]] = src_data[src_pos]; + } result_data[i] = info.componentId[src_data[src_pos]]; } } - // Handle any unfinished lanes and assign component IDs - AssignUnfinishedLanesToComponent(result, info, vdata_src, src_data, v_size); + // // Handle any unfinished lanes and assign component IDs + // AssignUnfinishedLanesToComponent(result, info, vdata_src, src_data, v_size); duckpgq_state->csr_to_delete.insert(info.csr_id); diff --git a/test/sql/scalar/weakly_connected_component.test b/test/sql/scalar/weakly_connected_component.test index a37585c3..184d78d6 100644 --- a/test/sql/scalar/weakly_connected_component.test +++ b/test/sql/scalar/weakly_connected_component.test @@ -214,3 +214,69 @@ select id, componentId from weakly_connected_component(pg_no_edge_table, student ---- Invalid Error: Table non_existent_edge not found in property graph pg_no_edge_table +statement ok +import database 'duckdb-pgq/data/SNB0.003'; + +statement ok +-CREATE PROPERTY GRAPH snb + VERTEX TABLES ( + Person + ) + EDGE TABLES ( + Person_knows_person SOURCE KEY (Person1Id) REFERENCES Person (id) + DESTINATION KEY (Person2Id) REFERENCES Person (id) + LABEL Knows); + +query II +from weakly_connected_component(snb, person, knows) order by componentId; +---- +14 0 +16 0 +32 0 +2199023255557 0 +2199023255573 0 +2199023255594 0 +6597069766702 0 +8796093022237 0 +8796093022244 0 +8796093022249 0 +10995116277761 0 +10995116277782 0 +13194139533342 0 +13194139533352 0 +13194139533355 0 +15393162788877 0 +17592186044443 0 +17592186044461 0 +19791209299968 0 +19791209299987 0 +21990232555527 0 +24189255811081 0 +24189255811109 0 +26388279066632 0 +26388279066641 0 +26388279066655 0 +26388279066658 0 +26388279066668 0 +28587302322180 0 +28587302322191 0 +28587302322196 0 +28587302322204 0 +28587302322223 0 +30786325577731 0 +30786325577740 0 +32985348833329 0 +35184372088834 0 +35184372088850 0 +35184372088856 0 +4398046511139 6 +8796093022234 8 +10995116277783 14 +10995116277808 15 +21990232555526 24 +28587302322209 37 +32985348833291 41 +32985348833318 42 +35184372088871 47 +37383395344394 48 +37383395344409 49 \ No newline at end of file