@@ -521,24 +521,26 @@ def _apply_inequality_clause(
521521 r_min = merged .get (f"{ right_col } __min_r" )
522522 r_max = merged .get (f"{ right_col } __max_r" )
523523
524- if l_min is None or l_max is None or r_min is None or r_max is None :
524+ if (
525+ l_min is None
526+ or l_max is None
527+ or r_min is None
528+ or r_max is None
529+ or f"{ left_col } __min" not in merged .columns
530+ or f"{ left_col } __max" not in merged .columns
531+ or f"{ right_col } __min_r" not in merged .columns
532+ or f"{ right_col } __max_r" not in merged .columns
533+ ):
525534 return merged
526535
527- l_min_any = cast (Any , l_min )
528- l_max_any = cast (Any , l_max )
529- r_min_any = cast (Any , r_min )
530- r_max_any = cast (Any , r_max )
531-
532536 if clause .op == ">" :
533- mask = l_min_any > r_max_any
534- elif clause .op == ">=" :
535- mask = l_min_any >= r_max_any
536- elif clause .op == "<" :
537- mask = l_max_any < r_min_any
538- else : # <=
539- mask = l_max_any <= r_min_any
540-
541- return merged [mask ]
537+ return merged [merged [f"{ left_col } __min" ] > merged [f"{ right_col } __max_r" ]]
538+ if clause .op == ">=" :
539+ return merged [merged [f"{ left_col } __min" ] >= merged [f"{ right_col } __max_r" ]]
540+ if clause .op == "<" :
541+ return merged [merged [f"{ left_col } __max" ] < merged [f"{ right_col } __min_r" ]]
542+ # <=
543+ return merged [merged [f"{ left_col } __max" ] <= merged [f"{ right_col } __min_r" ]]
542544
543545 @staticmethod
544546 def _evaluate_clause (series_left : Any , op : str , series_right : Any ) -> Any :
@@ -617,19 +619,13 @@ def _alias_for_step(self, step_index: int) -> Optional[str]:
617619
618620 @staticmethod
619621 def _concat_frames (frames : Sequence [DataFrameT ]) -> Optional [DataFrameT ]:
620- """Concatenate a sequence of pandas or cuDF frames, preserving type."""
621-
622622 if not frames :
623623 return None
624624 first = frames [0 ]
625- try :
626- if first .__class__ .__module__ .startswith ("cudf" ):
627- import cudf # type: ignore
625+ if first .__class__ .__module__ .startswith ("cudf" ):
626+ import cudf # type: ignore
628627
629- return cudf .concat (frames , ignore_index = True )
630- except Exception :
631- # Fall back to pandas concat when cuDF is unavailable or mismatched
632- pass
628+ return cudf .concat (frames , ignore_index = True )
633629 return pd .concat (frames , ignore_index = True )
634630
635631
0 commit comments