[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3932: [CARBONDATA-3994] Skip Order by for map task if it is a first sort column and use limit pushdown for array_contains filt

2020-10-20 Thread GitBox


ajantha-bhat commented on a change in pull request #3932:
URL: https://github.com/apache/carbondata/pull/3932#discussion_r508460403



##
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/strategy/CarbonLateDecodeStrategy.scala
##
@@ -984,6 +988,80 @@ private[sql] class CarbonLateDecodeStrategy extends 
SparkStrategy {
   null)(sparkSession)
 }
   }
+
+  object ExtractTakeOrderedAndProjectExec {
+
+def unapply(plan: LogicalPlan): Option[CarbonTakeOrderedAndProjectExec] = {
+  val allRelations = plan.collect { case logicalRelation: LogicalRelation 
=> logicalRelation }
+  // push down order by limit to carbon map task,
+  // only when there are only one CarbonDatasourceHadoopRelation
+  if (allRelations.size != 1 ||
+  allRelations.exists(x => 
!x.relation.isInstanceOf[CarbonDatasourceHadoopRelation])) {
+return None
+  }
+  //  check and Replace TakeOrderedAndProject with 
CarbonTakeOrderedAndProjectExec.
+  val relation = 
allRelations.head.relation.asInstanceOf[CarbonDatasourceHadoopRelation]
+  val sparkPlan = plan match {
+case ReturnAnswer(rootPlan) => rootPlan match {
+  case Limit(IntegerLiteral(limit), Sort(order, true, child)) =>
+TakeOrderedAndProjectExec(limit,
+  order,
+  child.output,
+  planLater(pushLimit(limit, child)))
+  case Limit(IntegerLiteral(limit), Project(projectList, Sort(order, 
true, child))) =>
+TakeOrderedAndProjectExec(limit, order, projectList, 
planLater(pushLimit(limit, child)))

Review comment:
   ok. Handled.





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




[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #3932: [CARBONDATA-3994] Skip Order by for map task if it is a first sort column and use limit pushdown for array_contains filt

2020-10-20 Thread GitBox


ajantha-bhat commented on a change in pull request #3932:
URL: https://github.com/apache/carbondata/pull/3932#discussion_r508460792



##
File path: 
integration/spark/src/main/scala/org/apache/spark/sql/execution/CarbonTakeOrderedAndProjectExec.scala
##
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution
+
+import org.apache.spark.rdd.RDD
+import org.apache.spark.serializer.Serializer
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.{Attribute, NamedExpression, 
SortOrder, UnsafeProjection}
+import 
org.apache.spark.sql.catalyst.expressions.codegen.LazilyGeneratedOrdering
+import org.apache.spark.sql.catalyst.plans.physical.{Partitioning, 
SinglePartition}
+import org.apache.spark.sql.execution.exchange.ShuffleExchangeExec
+import org.apache.spark.util.Utils
+
+// To skip the order at map task
+case class CarbonTakeOrderedAndProjectExec(
+limit: Int,
+sortOrder: Seq[SortOrder],
+projectList: Seq[NamedExpression],
+child: SparkPlan,
+skipMapOrder: Boolean = false,
+readFromHead: Boolean = true) extends UnaryExecNode {

Review comment:
   Both are case class, so cannot extend this. 





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