You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rxin <gi...@git.apache.org> on 2016/07/29 05:29:20 UTC

[GitHub] spark pull request #11514: [SPARK-13671] [SPARK-13311] [SQL] Use different p...

Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11514#discussion_r72743160
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/ExistingRDD.scala ---
    @@ -101,17 +101,76 @@ private[sql] case class LogicalRDD(
     private[sql] case class PhysicalRDD(
         output: Seq[Attribute],
         rdd: RDD[InternalRow],
    -    override val nodeName: String,
    -    override val metadata: Map[String, String] = Map.empty,
    -    isUnsafeRow: Boolean = false,
    -    override val outputPartitioning: Partitioning = UnknownPartitioning(0))
    +    override val nodeName: String) extends LeafNode {
    +
    +  private[sql] override lazy val metrics = Map(
    +    "numOutputRows" -> SQLMetrics.createLongMetric(sparkContext, "number of output rows"))
    +
    +  protected override def doExecute(): RDD[InternalRow] = {
    +    val numOutputRows = longMetric("numOutputRows")
    +    rdd.mapPartitionsInternal { iter =>
    +      val proj = UnsafeProjection.create(schema)
    +      iter.map { r =>
    +        numOutputRows += 1
    +        proj(r)
    +      }
    +    }
    +  }
    +
    +  override def simpleString: String = {
    +    s"Scan $nodeName${output.mkString("[", ",", "]")}"
    +  }
    +}
    +
    +/** Physical plan node for scanning data from a relation. */
    +private[sql] case class DataSourceScan(
    +    output: Seq[Attribute],
    +    rdd: RDD[InternalRow],
    +    @transient relation: BaseRelation,
    +    override val metadata: Map[String, String] = Map.empty)
       extends LeafNode with CodegenSupport {
     
    +  override val nodeName: String = relation.toString
    +
    +  // Ignore rdd when checking results
    +  override def sameResult(plan: SparkPlan ): Boolean = plan match {
    +    case other: DataSourceScan => relation == other.relation && metadata == other.metadata
    --- End diff --
    
    this is actually wrong because we cannot ignore the rdd, otherwise scans of different partitions are treated as "sameResult"!



---
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