Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ArrayType check on structfield_comparer.py function are_structfi… #49

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion chispa/structfield_comparer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chispa.six as six
from pyspark.sql.types import StructType
from pyspark.sql.types import StructType, ArrayType

def are_structfields_equal(sf1, sf2, ignore_nullability=False):
if ignore_nullability:
Expand All @@ -9,6 +9,8 @@ def are_structfields_equal(sf1, sf2, ignore_nullability=False):
return False
elif sf1.name != sf2.name:
return False
elif isinstance(sf1.dataType, ArrayType) and isinstance(sf2.dataType, ArrayType):
return True
elif isinstance(sf1.dataType, StructType) and isinstance(sf2.dataType, StructType):
for t1, t2 in six.moves.zip_longest(sf1.dataType, sf2.dataType):
if not are_structfields_equal(t1, t2, ignore_nullability):
Expand Down