Skip to content

Commit

Permalink
Also check condition in make_filter for None
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Mar 31, 2021
1 parent 3e2cdb1 commit 2bf5d93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions python/pyarrow/gandiva.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ cpdef make_projector(Schema schema, children, MemoryPool pool,

cpdef make_filter(Schema schema, Condition condition):
cdef shared_ptr[CFilter] result
if condition is None:
raise TypeError("Condition must not be None")
check_status(
Filter_Make(schema.sp_schema, condition.condition, &result))
return Filter.create(result)
Expand Down
10 changes: 4 additions & 6 deletions python/pyarrow/tests/test_gandiva.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ def test_rejects_none():
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])

Expand All @@ -395,14 +395,12 @@ def test_rejects_none():

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):
with pytest.raises(TypeError):
gandiva.make_filter(schema, None)


0 comments on commit 2bf5d93

Please sign in to comment.