Skip to content

Commit 251f99d

Browse files
committed
for now only allow dictionaries as input
1 parent 09b9980 commit 251f99d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/pyspark/context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,10 @@ def sql(self, sqlQuery):
475475
return SchemaRDD(self._ssql_ctx.sql(sqlQuery), self)
476476

477477
def applySchema(self, rdd):
478-
first = rdd.first()
479478
if (rdd.__class__ is SchemaRDD):
480479
raise Exception("Cannot apply schema to %s" % SchemaRDD.__name__)
480+
elif type(rdd.first()) is not dict:
481+
raise Exception("Only RDDs with dictionaries can be converted to %s" % SchemaRDD.__name__)
481482

482483
jrdd = self._sc._pythonToJavaMap(rdd._jrdd)
483484
srdd = self._ssql_ctx.applySchema(jrdd.rdd())

0 commit comments

Comments
 (0)