9
9
import pylibcudf as plc
10
10
11
11
from cudf_polars .dsl import expr
12
- from cudf_polars .dsl .ir import HConcat , Scan , Select , Union
12
+ from cudf_polars .dsl .expr import Col , Len
13
+ from cudf_polars .dsl .ir import Empty , HConcat , Scan , Select , Union
13
14
from cudf_polars .dsl .traversal import traversal
14
15
from cudf_polars .experimental .base import PartitionInfo
15
16
from cudf_polars .experimental .dispatch import lower_ir_node
@@ -116,6 +117,7 @@ def _(
116
117
and isinstance (child .children [0 ], Scan )
117
118
and child .children [0 ].predicate is None
118
119
):
120
+ # Special Case: Fast count.
119
121
scan = child .children [0 ]
120
122
count = scan .fast_count ()
121
123
dtype = ir .exprs [0 ].value .dtype
@@ -135,9 +137,18 @@ def _(
135
137
partition_info [new_node ] = PartitionInfo (count = 1 )
136
138
return new_node , partition_info
137
139
140
+ if not any (
141
+ isinstance (expr , (Col , Len )) for expr in traversal ([e .value for e in ir .exprs ])
142
+ ):
143
+ # Special Case: Selection does not depend on any columns.
144
+ new_node = ir .reconstruct ([input_ir := Empty ()])
145
+ partition_info [input_ir ] = partition_info [new_node ] = PartitionInfo (count = 1 )
146
+ return new_node , partition_info
147
+
138
148
if pi .count > 1 and not all (
139
149
expr .is_pointwise for expr in traversal ([e .value for e in ir .exprs ])
140
150
):
151
+ # Special Case: Multiple partitions with 1+ non-pointwise expressions.
141
152
try :
142
153
# Try decomposing the underlying expressions
143
154
return decompose_select (
0 commit comments