spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davies <...@git.apache.org>
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:

    https://github.com/apache/spark/pull/6081#discussion_r30458679
  
    --- Diff: python/pyspark/sql/context.py ---
    @@ -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,
with
    +        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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message