jorisvandenbossche commented on a change in pull request #8088:
URL: https://github.com/apache/arrow/pull/8088#discussion_r492666980
##########
File path: python/pyarrow/array.pxi
##########
@@ -21,28 +21,28 @@ import warnings
cdef _sequence_to_array(object sequence, object mask, object size,
DataType type, CMemoryPool* pool, c_bool from_pandas):
- cdef int64_t c_size
- cdef PyConversionOptions options
+ cdef:
+ int64_t c_size
+ PyConversionOptions options
+ shared_ptr[CChunkedArray] chunked
if type is not None:
options.type = type.sp_type
if size is not None:
options.size = size
- options.pool = pool
options.from_pandas = from_pandas
- options.ignore_timezone = os.environ.get('PYARROW_IGNORE_TIMEZONE', False)
Review comment:
It wasn't catched by any tests?
##########
File path: python/pyarrow/tests/test_convert_builtin.py
##########
@@ -1513,6 +1519,108 @@ def test_struct_from_tuples():
pa.array([tup], type=ty)
+def test_struct_from_list_of_pairs():
+ ty = pa.struct([
+ pa.field('a', pa.int32()),
+ pa.field('b', pa.string()),
+ pa.field('c', pa.bool_())
+ ])
+ data = [
+ [('a', 5), ('b', 'foo'), ('c', True)],
+ [('a', 6), ('b', 'bar'), ('c', False)],
+ None
+ ]
+ arr = pa.array(data, type=ty)
+ assert arr.to_pylist() == [
+ {'a': 5, 'b': 'foo', 'c': True},
+ {'a': 6, 'b': 'bar', 'c': False},
+ None
+ ]
+
+ # test with duplicated field names
+ ty = pa.struct([
+ pa.field('a', pa.int32()),
+ pa.field('a', pa.string()),
+ pa.field('b', pa.bool_())
+ ])
+ data = [
+ [('a', 5), ('a', 'foo'), ('b', True)],
+ [('a', 6), ('a', 'bar'), ('b', False)],
+ ]
+ arr = pa.array(data, type=ty)
+ with pytest.raises(KeyError):
+ # TODO(kszucs): ARROW-9997
+ arr.to_pylist()
+
+ # test with empty elements
+ ty = pa.struct([
+ pa.field('a', pa.int32()),
+ pa.field('b', pa.string()),
+ pa.field('c', pa.bool_())
+ ])
+ data = [
+ [],
+ [('a', 5), ('b', 'foo'), ('c', True)],
+ [('a', 2), ('b', 'baz')],
+ [('a', 1), ('b', 'bar'), ('c', False), ('d', 'julia')],
Review comment:
Since the *order* matters when constructing from pairs (based on the
test below), I would personally expect additional elements would also not be
allowed (BTW, what actually happens if the additional element is not in the
last position? Maybe add a test for that as well?).
While when constructing from dicts also the order does not matter I suppose?
So this could be more tolerant
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]