You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/26 17:11:57 UTC

[GitHub] dongjoon-hyun commented on a change in pull request #23873: [SPARK-26975][SQL] Support nested-column pruning over limit/sample/repartition

dongjoon-hyun commented on a change in pull request #23873: [SPARK-26975][SQL] Support nested-column pruning over limit/sample/repartition
URL: https://github.com/apache/spark/pull/23873#discussion_r260392467
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnPruning.scala
 ##########
 @@ -0,0 +1,193 @@
+/*
+ * 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.catalyst.optimizer
+
+import scala.collection.mutable
+
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.catalyst.plans.QueryPlan
+import org.apache.spark.sql.catalyst.plans.logical._
+import org.apache.spark.sql.types.StructType
+
+/**
+ * This aims to handle nested column pruning pattern inside `ColumnPruning` optimizer rule.
+ * If a project or its child references to nested fields, and not all the fields
+ * in a nested attribute are used, we can create a new [[CreateNamedStruct]] containing only
+ * subset of the fields as a new project in the child.
+ */
+object NestedColumnPruning {
+
+  type ExprMap = Map[Expression, Expression]
+  type RequiredFieldMap = Map[Attribute, Set[GetStructField]]
+
+  def unapply(plan: LogicalPlan): Option[(Map[ExprId, Alias], ExprMap)] = plan match {
+    case p @ Project(_, child) if canProjectPushThrough(child) =>
 
 Review comment:
   Thank you for review. Yep. Those plans (having expression replacement) will be handled in my PR~

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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