MCPcopy Create free account
hub / github.com/apache/arrow / test_table

Function test_table

python/pyarrow/tests/test_gandiva.py:67–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66@pytest.mark.gandiva
67def 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

Callers

nothing calls this directly

Calls 5

to_batchesMethod · 0.80
equalsMethod · 0.80
arrayMethod · 0.45
fieldMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected