()
| 65 | |
| 66 | @pytest.mark.gandiva |
| 67 | def test_table(): |
| 68 | import pyarrow.gandiva as gandiva |
| 69 | |
| 70 | table = pa.Table.from_arrays([pa.array([1.0, 2.0]), pa.array([3.0, 4.0])], |
| 71 | ['a', 'b']) |
| 72 | |
| 73 | builder = gandiva.TreeExprBuilder() |
| 74 | node_a = builder.make_field(table.schema.field("a")) |
| 75 | node_b = builder.make_field(table.schema.field("b")) |
| 76 | |
| 77 | sum = builder.make_function("add", [node_a, node_b], pa.float64()) |
| 78 | |
| 79 | field_result = pa.field("c", pa.float64()) |
| 80 | expr = builder.make_expression(sum, field_result) |
| 81 | |
| 82 | projector = gandiva.make_projector( |
| 83 | table.schema, [expr], pa.default_memory_pool()) |
| 84 | |
| 85 | # TODO: Add .evaluate function which can take Tables instead of |
| 86 | # RecordBatches |
| 87 | r, = projector.evaluate(table.to_batches()[0]) |
| 88 | |
| 89 | e = pa.array([4.0, 6.0]) |
| 90 | assert r.equals(e) |
| 91 | |
| 92 | |
| 93 | @pytest.mark.gandiva |
nothing calls this directly
no test coverage detected