kszucs commented on a change in pull request #8349: URL: https://github.com/apache/arrow/pull/8349#discussion_r500988522
########## File path: python/pyarrow/tests/strategies.py ########## @@ -124,39 +132,67 @@ def fields(draw, type_strategy=primitive_types): def list_types(item_strategy=primitive_types): return ( st.builds(pa.list_, item_strategy) | - st.builds(pa.large_list, item_strategy) + st.builds(pa.large_list, item_strategy) | + st.builds( + pa.list_, + item_strategy, + st.integers(min_value=0, max_value=16) + ) ) -def struct_types(item_strategy=primitive_types): - return st.builds(pa.struct, st.lists(fields(item_strategy))) - - -def complex_types(inner_strategy=primitive_types): - return list_types(inner_strategy) | struct_types(inner_strategy) - - -def nested_list_types(item_strategy=primitive_types, max_leaves=3): - return st.recursive(item_strategy, list_types, max_leaves=max_leaves) +@st.composite +def struct_types(draw, item_strategy=primitive_types): + fields_strategy = st.lists(fields(item_strategy)) + fields_rendered = draw(fields_strategy) + field_names = [field.name for field in fields_rendered] + # check that field names are unique, see ARROW-9997 + h.assume(len(set(field_names)) == len(field_names)) + return pa.struct(fields_rendered) + + +def dictionary_types(key_strategy=None, value_strategy=None): + key_strategy = key_strategy or signed_integer_types + value_strategy = value_strategy or st.one_of( + bool_type, + integer_types, + st.sampled_from([pa.float32(), pa.float64()]), + binary_type, + string_type, + fixed_size_binary_type, + ) + return st.builds(pa.dictionary, key_strategy, value_strategy) -def nested_struct_types(item_strategy=primitive_types, max_leaves=3): - return st.recursive(item_strategy, struct_types, max_leaves=max_leaves) +@st.composite +def map_types(draw, key_strategy=primitive_types, + item_strategy=primitive_types): + key_type = draw(key_strategy) + h.assume(not pa.types.is_null(key_type)) + value_type = draw(item_strategy) + return pa.map_(key_type, value_type) -def nested_complex_types(inner_strategy=primitive_types, max_leaves=3): - return st.recursive(inner_strategy, complex_types, max_leaves=max_leaves) +# union type +# extension type Review comment: Created a follow-up jira https://issues.apache.org/jira/browse/ARROW-10212 ---------------------------------------------------------------- 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: us...@infra.apache.org