MCPcopy Create free account
hub / github.com/apache/arrow / test_schema_merge

Function test_schema_merge

python/pyarrow/tests/test_schema.py:747–787  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

745
746
747def test_schema_merge():
748 a = pa.schema([
749 pa.field('foo', pa.int32()),
750 pa.field('bar', pa.string()),
751 pa.field('baz', pa.list_(pa.int8()))
752 ])
753 b = pa.schema([
754 pa.field('foo', pa.int32()),
755 pa.field('qux', pa.bool_())
756 ])
757 c = pa.schema([
758 pa.field('quux', pa.dictionary(pa.int32(), pa.string()))
759 ])
760 d = pa.schema([
761 pa.field('foo', pa.int64()),
762 pa.field('qux', pa.bool_())
763 ])
764
765 result = pa.unify_schemas([a, b, c])
766 expected = pa.schema([
767 pa.field('foo', pa.int32()),
768 pa.field('bar', pa.string()),
769 pa.field('baz', pa.list_(pa.int8())),
770 pa.field('qux', pa.bool_()),
771 pa.field('quux', pa.dictionary(pa.int32(), pa.string()))
772 ])
773 assert result.equals(expected)
774
775 with pytest.raises(pa.ArrowTypeError):
776 pa.unify_schemas([b, d])
777
778 # ARROW-14002: Try with tuple instead of list
779 result = pa.unify_schemas((a, b, c))
780 assert result.equals(expected)
781
782 result = pa.unify_schemas([b, d], promote_options="permissive")
783 assert result.equals(d)
784
785 # raise proper error when passing a non-Schema value
786 with pytest.raises(TypeError):
787 pa.unify_schemas([a, 1])
788
789
790def test_undecodable_metadata():

Callers

nothing calls this directly

Calls 5

equalsMethod · 0.80
schemaMethod · 0.45
fieldMethod · 0.45
stringMethod · 0.45
dictionaryMethod · 0.45

Tested by

no test coverage detected