Skip to content

Commit

Permalink
Update context.py
Browse files Browse the repository at this point in the history
Turn iterator into list.
  • Loading branch information
Davies Liu committed Jun 4, 2015
1 parent eb24531 commit 8d9292d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/pyspark/sql/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _inferSchemaFromList(self, data):
"""
if not data:
raise ValueError("can not infer schema from empty dataset")
first = next(iter(data))
first = data[0]
if type(first) is dict:
warnings.warn("inferring schema from dict is deprecated,"
"please use pyspark.sql.Row instead")
Expand Down Expand Up @@ -341,6 +341,8 @@ def createDataFrame(self, data, schema=None, samplingRatio=None):
data = [r.tolist() for r in data.to_records(index=False)]

if not isinstance(data, RDD):
if not isinstance(data, list):
data = list(data)
try:
# data could be list, tuple, generator ...
rdd = self._sc.parallelize(data)
Expand Down

0 comments on commit 8d9292d

Please sign in to comment.