@@ -504,6 +504,7 @@ def connectedComponents(
504504 algorithm : str = "graphframes" ,
505505 checkpointInterval : int = 2 ,
506506 broadcastThreshold : int = 1000000 ,
507+ useLabelsAsComponents : bool = False ,
507508 ) -> DataFrame :
508509 class ConnectedComponents (LogicalPlan ):
509510 def __init__ (
@@ -513,28 +514,29 @@ def __init__(
513514 algorithm : str ,
514515 checkpoint_interval : int ,
515516 broadcast_threshold : int ,
517+ use_labels_as_components : bool ,
516518 ) -> None :
517519 super ().__init__ (None )
518520 self .v = v
519521 self .e = e
520522 self .algorithm = algorithm
521523 self .checkpoint_interval = checkpoint_interval
522524 self .broadcast_threshold = broadcast_threshold
525+ self .useLabelsAsComponents = use_labels_as_components
523526
524- def plan (self , session : SparkConnectClient ) -> proto .Relation :
525- graphframes_api_call = GraphFrameConnect ._get_pb_api_message (
526- self .v , self .e , session
527- )
528- graphframes_api_call .connected_components .CopyFrom (
529- pb .ConnectedComponents (
530- algorithm = self .algorithm ,
531- checkpoint_interval = self .checkpoint_interval ,
532- broadcast_threshold = self .broadcast_threshold ,
533- )
527+ def plan (self , session : SparkConnectClient ) -> proto .Relation :
528+ graphframes_api_call = GraphFrameConnect ._get_pb_api_message (self .v , self .e , session )
529+ graphframes_api_call .connected_components .CopyFrom (
530+ pb .ConnectedComponents (
531+ algorithm = self .algorithm ,
532+ checkpoint_interval = self .checkpoint_interval ,
533+ broadcast_threshold = self .broadcast_threshold ,
534+ use_labels_as_components = self .use_labels_as_components ,
534535 )
535- plan = self ._create_proto_relation ()
536- plan .extension .Pack (graphframes_api_call )
537- return plan
536+ )
537+ plan = self ._create_proto_relation ()
538+ plan .extension .Pack (graphframes_api_call )
539+ return plan
538540
539541 return _dataframe_from_plan (
540542 ConnectedComponents (
@@ -543,6 +545,7 @@ def plan(self, session: SparkConnectClient) -> proto.Relation:
543545 algorithm ,
544546 checkpointInterval ,
545547 broadcastThreshold ,
548+ useLabelsAsComponents ,
546549 ),
547550 self ._spark ,
548551 )
0 commit comments