rdblue commented on a change in pull request #3763: URL: https://github.com/apache/iceberg/pull/3763#discussion_r773301162
########## File path: spark/v3.2/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala ########## @@ -0,0 +1,123 @@ +/* + * 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 + +import org.apache.spark.sql.catalyst.util.ArrayData +import org.apache.spark.sql.catalyst.util.MapData +import org.apache.spark.sql.types.DataType +import org.apache.spark.sql.types.Decimal +import org.apache.spark.sql.types.StructType +import org.apache.spark.unsafe.types.CalendarInterval +import org.apache.spark.unsafe.types.UTF8String + +/** + * An InternalRow that projects particular columns from another InternalRow without copying + * the underlying data. + */ +case class ProjectingInternalRow(schema: StructType, colOrdinals: Seq[Int]) extends InternalRow { + assert(schema.size == colOrdinals.size) + + private var row: InternalRow = _ + + override def numFields: Int = colOrdinals.size + + def project(row: InternalRow): Unit = { + this.row = row + } + + override def setNullAt(i: Int): Unit = { + throw new UnsupportedOperationException("Cannot modify InternalRowProjection") + } + + override def update(i: Int, value: Any): Unit = { + throw new UnsupportedOperationException("Cannot modify InternalRowProjection") + } + + override def copy(): InternalRow = { Review comment: Assuming it is an `UnsafeRow` passed in, you might be right. I'd just leave this as is. -- 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]
