Skip to content

Commit 349b119

Browse files
committed
fix python 3
1 parent 97dcac2 commit 349b119

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

python/pyspark/sql/group.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ class GroupedIterator(object):
231231

232232
def __init__(self, inputs):
233233
self.inputs = BufferedIterator(inputs)
234-
self.current_input = inputs.next()
234+
self.current_input = next(inputs)
235235
self.current_key = self.current_input[0]
236236
self.current_values = GroupValuesIterator(self)
237237

238238
def __iter__(self):
239239
return self
240240

241+
def __next__(self):
242+
return self.next()
243+
241244
def next(self):
242245
if self.current_values is None:
243246
self._fetch_next_group()
@@ -248,11 +251,11 @@ def next(self):
248251

249252
def _fetch_next_group(self):
250253
if self.current_input is None:
251-
self.current_input = self.inputs.next()
254+
self.current_input = next(self.inputs)
252255

253256
# Skip to next group, or consume all inputs and throw StopIteration exception.
254257
while self.current_input[0] == self.current_key:
255-
self.current_input = self.inputs.next()
258+
self.current_input = next(self.inputs)
256259

257260
self.current_key = self.current_input[0]
258261
self.current_values = GroupValuesIterator(self)
@@ -267,6 +270,9 @@ def __init__(self, outter):
267270
def __iter__(self):
268271
return self
269272

273+
def __next__(self):
274+
return self.next()
275+
270276
def next(self):
271277
if self.outter.current_input is None:
272278
self._fetch_next_value()
@@ -277,7 +283,7 @@ def next(self):
277283

278284
def _fetch_next_value(self):
279285
if self.outter.inputs.head()[0] == self.outter.current_key:
280-
self.outter.current_input = self.outter.inputs.next()
286+
self.outter.current_input = next(self.outter.inputs)
281287
else:
282288
raise StopIteration
283289

@@ -292,17 +298,20 @@ def __init__(self, iterator):
292298
def __iter__(self):
293299
return self
294300

301+
def __next__(self):
302+
return self.next()
303+
295304
def next(self):
296305
if self.buffered is None:
297-
return self.iterator.next()
306+
return next(self.iterator)
298307
else:
299308
item = self.buffered
300309
self.buffered = None
301310
return item
302311

303312
def head(self):
304313
if self.buffered is None:
305-
self.buffered = self.iterator.next()
314+
self.buffered = next(self.iterator)
306315
return self.buffered
307316

308317

0 commit comments

Comments
 (0)