Skip to content

Commit

Permalink
ARROW-7027: [Python] Correctly raise error in pa.table(..) on invalid…
Browse files Browse the repository at this point in the history
… input

https://issues.apache.org/jira/browse/ARROW-7027

Closes #5758 from jorisvandenbossche/ARROW-7027 and squashes the following commits:

862ca8a <Joris Van den Bossche> ARROW-7027:  Correctly raise error in pa.table(..) on invalid input

Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Wes McKinney <wesm+git@apache.org>
  • Loading branch information
jorisvandenbossche authored and wesm committed Oct 30, 2019
1 parent 41753ac commit 102410c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/pyarrow/table.pxi
Expand Up @@ -1635,7 +1635,8 @@ def table(data, names=None, schema=None, metadata=None):
"passing a pandas DataFrame")
return Table.from_pandas(data, schema=schema)
else:
return TypeError("Expected pandas DataFrame or python dictionary")
raise TypeError(
"Expected pandas DataFrame, python dictionary or list of arrays")


def concat_tables(tables):
Expand Down
5 changes: 5 additions & 0 deletions python/pyarrow/tests/test_table.py
Expand Up @@ -1183,6 +1183,11 @@ def test_table_factory_function_args_pandas():
assert table.column('a').type == pa.int32()


def test_table_factory_function_invalid_input():
with pytest.raises(TypeError, match="Expected pandas DataFrame, python"):
pa.table("invalid input")


def test_table_function_unicode_schema():
col_a = "äääh"
col_b = "öööf"
Expand Down

0 comments on commit 102410c

Please sign in to comment.