()
| 227 | |
| 228 | @pytest.mark.gandiva |
| 229 | def test_boolean(): |
| 230 | import pyarrow.gandiva as gandiva |
| 231 | |
| 232 | table = pa.Table.from_arrays([ |
| 233 | pa.array([1., 31., 46., 3., 57., 44., 22.]), |
| 234 | pa.array([5., 45., 36., 73., 83., 23., 76.])], |
| 235 | ['a', 'b']) |
| 236 | |
| 237 | builder = gandiva.TreeExprBuilder() |
| 238 | node_a = builder.make_field(table.schema.field("a")) |
| 239 | node_b = builder.make_field(table.schema.field("b")) |
| 240 | fifty = builder.make_literal(50.0, pa.float64()) |
| 241 | eleven = builder.make_literal(11.0, pa.float64()) |
| 242 | |
| 243 | cond_1 = builder.make_function("less_than", [node_a, fifty], pa.bool_()) |
| 244 | cond_2 = builder.make_function("greater_than", [node_a, node_b], |
| 245 | pa.bool_()) |
| 246 | cond_3 = builder.make_function("less_than", [node_b, eleven], pa.bool_()) |
| 247 | cond = builder.make_or([builder.make_and([cond_1, cond_2]), cond_3]) |
| 248 | condition = builder.make_condition(cond) |
| 249 | |
| 250 | filter = gandiva.make_filter(table.schema, condition) |
| 251 | result = filter.evaluate(table.to_batches()[0], pa.default_memory_pool()) |
| 252 | assert result.to_array().equals(pa.array([0, 2, 5], type=pa.uint32())) |
| 253 | |
| 254 | |
| 255 | @pytest.mark.gandiva |
nothing calls this directly
no test coverage detected