sarutak commented on a change in pull request #29681:
URL: https://github.com/apache/spark/pull/29681#discussion_r484844175
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala
##########
@@ -562,58 +565,64 @@ case class RangeExec(range:
org.apache.spark.sql.catalyst.plans.logical.Range)
protected override def doExecute(): RDD[InternalRow] = {
val numOutputRows = longMetric("numOutputRows")
- sqlContext
- .sparkContext
- .parallelize(0 until numSlices, numSlices)
- .mapPartitionsWithIndex { (i, _) =>
- val partitionStart = (i * numElements) / numSlices * step + start
- val partitionEnd = (((i + 1) * numElements) / numSlices) * step + start
- def getSafeMargin(bi: BigInt): Long =
- if (bi.isValidLong) {
- bi.toLong
- } else if (bi > 0) {
- Long.MaxValue
- } else {
- Long.MinValue
- }
- val safePartitionStart = getSafeMargin(partitionStart)
- val safePartitionEnd = getSafeMargin(partitionEnd)
- val rowSize = UnsafeRow.calculateBitSetWidthInBytes(1) +
LongType.defaultSize
- val unsafeRow = UnsafeRow.createFromByteArray(rowSize, 1)
- val taskContext = TaskContext.get()
-
- val iter = new Iterator[InternalRow] {
- private[this] var number: Long = safePartitionStart
- private[this] var overflow: Boolean = false
- private[this] val inputMetrics =
taskContext.taskMetrics().inputMetrics
-
- override def hasNext =
- if (!overflow) {
- if (step > 0) {
- number < safePartitionEnd
- } else {
- number > safePartitionEnd
- }
- } else false
-
- override def next() = {
- val ret = number
- number += step
- if (number < ret ^ step < 0) {
- // we have Long.MaxValue + Long.MaxValue < Long.MaxValue
- // and Long.MinValue + Long.MinValue > Long.MinValue, so iff the
step causes a step
- // back, we are pretty sure that we have an overflow.
- overflow = true
+ if (isEmptyRange) {
+ new EmptyRDD[InternalRow](sqlContext.sparkContext)
+ } else {
Review comment:
For reviewers: There are no changes within this `else` block.
The actual change is `if` block above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]