spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davies <>
Subject [GitHub] spark pull request: [SPARK-7150] add range() api
Date Sat, 16 May 2015 05:26:48 GMT
Github user davies commented on a diff in the pull request:
    --- Diff: python/pyspark/sql/ ---
    @@ -427,6 +428,31 @@ def func(iterator):
                 df = self._ssql_ctx.jsonRDD(jrdd.rdd(), scala_datatype)
             return DataFrame(df, self)
    +    def range(self, start, end, step=None, num_partitions=None):
    +        """Creates a [[DataFrame]] with a single [[LongType]] column named `id`, containing
    +        elements in an range from `start` to `end`(exclusive) with an Integer step value,
    +        partition number specified.
    +        """
    +        step = 1 if step is None else step
    +        num_partitions = self._sc.defaultParallelism if num_partitions is None else num_partitions
    +        if not isinstance(start, (int, long)):
    +            raise TypeError("start should be long")
    --- End diff --
    There is no `long` in Python 3, so we should do this (accept long in python 2):
    if not isinstance(start, (int, long)):
      raise TypeError("start should be int")
    Python 2 will convert value larger than sys.maxint to long.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message