File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed
Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -829,10 +829,12 @@ def _materialize_local(
829829 sampled_batches = execute_result .batches (sample_rate = fraction )
830830 raw_df = sampled_batches .to_pandas ()
831831 else : # uniform sample with random state requires a full follow-up query
832- return self ._downsample (
833- fraction = fraction ,
832+ down_sampled_block = self .split (
833+ fracs = ( fraction ,) ,
834834 random_state = sample_config .random_state ,
835- )._materialize_local (
835+ sort = False ,
836+ )[0 ]
837+ return down_sampled_block ._materialize_local (
836838 MaterializationOptions (ordered = materialize_options .ordered )
837839 )
838840 else :
@@ -841,14 +843,6 @@ def _materialize_local(
841843 df .set_axis (self .column_labels , axis = 1 , copy = False )
842844 return df , execute_result .query_job
843845
844- def _downsample (self , fraction : float , random_state ) -> Block :
845- block = self .split (
846- fracs = (fraction ,),
847- random_state = random_state ,
848- sort = False ,
849- )[0 ]
850- return block
851-
852846 def split (
853847 self ,
854848 ns : Iterable [int ] = (),
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ def execution_metadata(self) -> ExecutionMetadata:
132132 def schema (self ):
133133 return schema
134134
135- def batches (self ) -> ResultsIterator :
135+ def batches (self , sample_rate = None ) -> ResultsIterator :
136136 return ResultsIterator (
137137 arrow_batches_val ,
138138 self .schema ,
You can’t perform that action at this time.
0 commit comments