Skip to content

Commit

Permalink
Fixed style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Ganelin committed Jun 18, 2015
1 parent e7ba7e0 commit 41ab686
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,27 +511,31 @@ def test_between_function(self):
def test_struct_type(self):
from pyspark.sql.types import StructType, StringType, StructField
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
struct2 = StructType([StructField("f1", StringType(), True), StructField("f2", StringType(), True, None)])
struct2 = StructType([StructField("f1", StringType(), True),
StructField("f2", StringType(), True, None)])
self.assertEqual(struct1, struct2)

struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
struct2 = StructType([StructField("f1", StringType(), True)])
self.assertNotEqual(struct1, struct2)

struct1 = (StructType().add(StructField("f1", StringType(), True)).add(StructField("f2", StringType(), True, None)))
struct2 = StructType([StructField("f1", StringType(), True), StructField("f2", StringType(), True, None)])
struct1 = (StructType().add(StructField("f1", StringType(), True))
.add(StructField("f2", StringType(), True, None)))
struct2 = StructType([StructField("f1", StringType(), True),
StructField("f2", StringType(), True, None)])
self.assertEqual(struct1, struct2)

struct1 = (StructType().add(StructField("f1", StringType(), True)).add(StructField("f2", StringType(), True, None)))
struct1 = (StructType().add(StructField("f1", StringType(), True))
.add(StructField("f2", StringType(), True, None)))
struct2 = StructType([StructField("f1", StringType(), True)])
self.assertEqual(struct1, struct2)

# Catch exception raised during improper construction
try:
struct1 = StructType().add("name")
self.assertEqual(1,0)
self.assertEqual(1, 0)
except ValueError:
self.assertEqual(1,1)
self.assertEqual(1, 1)

def test_save_and_load(self):
df = self.df
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/sql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def add(self, name_or_struct_field, data_type=None, nullable=True, metadata=None
self.fields.append(name_or_struct_field)
return self
else:
if isinstance(name_or_struct_field, str) and data_type==None:
if isinstance(name_or_struct_field, str) and data_type is None:
raise ValueError("Must specify DataType if passing name of struct_field to create.")
self.fields.append(StructField(name_or_struct_field, data_type, nullable, metadata))
return self
Expand Down

0 comments on commit 41ab686

Please sign in to comment.