Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
da-tubi committed Mar 23, 2021
1 parent ddda826 commit e185149
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/pyspark/sql/pandas/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import Optional

from pyspark.serializers import Serializer, read_int, write_int, UTF8Deserializer
from pyspark.sql.types import ArrayType, DataType, UserDefinedType
from pyspark.sql.types import ArrayType, DataType, UserDefinedType, StructType
from pyspark.sql.pandas.types import to_arrow_type


Expand Down Expand Up @@ -193,7 +193,7 @@ def create_array(s, t: pa.DataType, dt: Optional[DataType] = None):
raise e
return array

def create_arrs_names(s, t: pa.DataType, dt: Optional[DataType] = None):
def create_arrs_names(s, t: pa.DataType, dt: Optional[StructType] = None):
# If input s is empty with zero columns, return empty Arrays with struct
if len(s) == 0 and len(s.columns) == 0:
return [(pa.array([], type=field.type), field.name) for field in t]
Expand Down Expand Up @@ -240,6 +240,8 @@ def create_arrs_names(s, t: pa.DataType, dt: Optional[DataType] = None):
raise ValueError("A field of type StructType expects a pandas.DataFrame, "
"but got: %s" % str(type(s)))
if isinstance(dt, DataType):
type_not_match = "dt must be instance of StructType when t is pyarrow struct"
assert isinstance(dt, StructType), type_not_match
arrs_names = create_arrs_names(s, t, dt)
else:
arrs_names = create_arrs_names(s, t)
Expand Down

0 comments on commit e185149

Please sign in to comment.