Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Dec 9, 2021
1 parent 49de0bf commit 14752e4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions python/pyarrow/tests/test_gandiva.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,44 @@ def test_to_string():
field_y = builder.make_field(pa.field('y', pa.bool_()))
and_node = builder.make_and([func_node, field_y])
assert str(and_node) == 'bool not((bool) z) && (bool) y'


@pytest.mark.gandiva
def test_rejects_none():
import pyarrow.gandiva as gandiva

builder = gandiva.TreeExprBuilder()

field_x = pa.field('x', pa.int32())
schema = pa.schema([field_x])
literal_true = builder.make_literal(True, pa.bool_())

with pytest.raises(TypeError):
builder.make_field(None)

with pytest.raises(TypeError):
builder.make_if(literal_true, None, None, None)

with pytest.raises(TypeError):
builder.make_and([literal_true, None])

with pytest.raises(TypeError):
builder.make_or([None, literal_true])

with pytest.raises(TypeError):
builder.make_in_expression(None, [1, 2, 3], pa.int32())

with pytest.raises(TypeError):
builder.make_expression(None, field_x)

with pytest.raises(TypeError):
builder.make_condition(None)

with pytest.raises(TypeError):
builder.make_function('less_than', [literal_true, None], pa.bool_())

with pytest.raises(TypeError):
gandiva.make_projector(schema, [None])

with pytest.raises(pa.lib.ArrowInvalid):
gandiva.make_filter(schema, None)

0 comments on commit 14752e4

Please sign in to comment.