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

Function test_regex

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

Source from the content-addressed store, hash-verified

294
295@pytest.mark.gandiva
296def test_regex():
297 import pyarrow.gandiva as gandiva
298
299 elements = ["park", "sparkle", "bright spark and fire", "spark"]
300 data = pa.array(elements, type=pa.string())
301 table = pa.Table.from_arrays([data], names=['a'])
302
303 builder = gandiva.TreeExprBuilder()
304 node_a = builder.make_field(table.schema.field("a"))
305 regex = builder.make_literal("%spark%", pa.string())
306 like = builder.make_function("like", [node_a, regex], pa.bool_())
307
308 field_result = pa.field("b", pa.bool_())
309 expr = builder.make_expression(like, field_result)
310
311 projector = gandiva.make_projector(
312 table.schema, [expr], pa.default_memory_pool())
313
314 r, = projector.evaluate(table.to_batches()[0])
315 b = pa.array([False, True, True, True], type=pa.bool_())
316 assert r.equals(b)
317
318
319@pytest.mark.gandiva

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected