allisonwang-db commented on code in PR #47884: URL: https://github.com/apache/spark/pull/47884#discussion_r1736886198
########## sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTranspose.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.analysis + +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.SparkSession +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.catalyst.expressions.{Alias, Ascending, Attribute, AttributeReference, Cast, IsNotNull, Literal, SortOrder} +import org.apache.spark.sql.catalyst.plans.logical.{Filter, Limit, LogicalPlan, Project, Sort, Transpose} +import org.apache.spark.sql.catalyst.rules.Rule +import org.apache.spark.sql.catalyst.trees.TreePattern +import org.apache.spark.sql.internal.SQLConf +import org.apache.spark.sql.types.{AtomicType, DataType, StringType} +import org.apache.spark.unsafe.types.UTF8String + + +class ResolveTranspose(sparkSession: SparkSession) extends Rule[LogicalPlan] { Review Comment: Can we include some high-level transpose logic in the docstring for this rule? ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala: ########## @@ -1474,6 +1474,31 @@ case class Pivot( override protected def withNewChildInternal(newChild: LogicalPlan): Pivot = copy(child = newChild) } +/** + * A constructor for creating a transpose, which will later be converted Review Comment: Can we be more specific on "later" here? like during analysis stage by which rule. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala: ########## @@ -1474,6 +1474,31 @@ case class Pivot( override protected def withNewChildInternal(newChild: LogicalPlan): Pivot = copy(child = newChild) } +/** + * A constructor for creating a transpose, which will later be converted + * to a [[LocalRelation]] during the query optimization. + * + * The result of the transpose operation is held in the `data` field, and the corresponding + * schema is stored in the `output` field. The `Transpose` node does not depend on any child + * logical plans after the data has been collected and transposed. + * + * @param output A sequence of output attributes representing the schema of the transposed data. + * @param data A sequence of [[InternalRow]] containing the transposed data. + */ +case class Transpose( + output: Seq[Attribute], + data: Seq[InternalRow] = Nil, + hasNonIndexColumns: Boolean = true Review Comment: This parameter is not documented. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
