ajantha-bhat commented on a change in pull request #3538: [CARBONDATA-3637] Optimize insert into flow URL: https://github.com/apache/carbondata/pull/3538#discussion_r376342021
########## File path: integration/spark2/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ########## @@ -957,24 +987,36 @@ object CarbonDataRDDFactory { private def loadDataFrame( sqlContext: SQLContext, dataFrame: Option[DataFrame], + scanResultRDD: Option[RDD[InternalRow]], carbonLoadModel: CarbonLoadModel ): Array[(String, (LoadMetadataDetails, ExecutionErrors))] = { try { - val rdd = dataFrame.get.rdd - + val rdd = if (dataFrame.isDefined) { + dataFrame.get.rdd + } else { + scanResultRDD.get + } val nodeNumOfData = rdd.partitions.flatMap[String, Array[String]] { p => DataLoadPartitionCoalescer.getPreferredLocs(rdd, p).map(_.host) }.distinct.length val nodes = DistributionUtil.ensureExecutorsByNumberAndGetNodeList( nodeNumOfData, sqlContext.sparkContext) - val newRdd = new DataLoadCoalescedRDD[Row](sqlContext.sparkSession, rdd, nodes.toArray - .distinct) - + val newRdd = + if (dataFrame.isDefined) { + new DataLoadCoalescedRDD[Row](sqlContext.sparkSession, dataFrame.get.rdd, nodes.toArray + .distinct) + } else { + new DataLoadCoalescedRDD[InternalRow](sqlContext.sparkSession, Review comment: ok ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services