rdblue commented on code in PR #6622: URL: https://github.com/apache/iceberg/pull/6622#discussion_r1094789846
########## spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/source/SparkLocalScan.java: ########## @@ -0,0 +1,59 @@ +/* + * 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.iceberg.spark.source; + +import java.util.Arrays; +import java.util.stream.Collectors; +import org.apache.iceberg.Table; +import org.apache.spark.sql.catalyst.InternalRow; +import org.apache.spark.sql.connector.read.LocalScan; +import org.apache.spark.sql.types.StructField; +import org.apache.spark.sql.types.StructType; + +class SparkLocalScan implements LocalScan { + + private final Table table; + private final StructType aggregateSchema; + private final InternalRow[] rows; + + SparkLocalScan(Table table, StructType aggregateSchema, InternalRow[] rows) { + this.table = table; + this.aggregateSchema = aggregateSchema; + this.rows = rows; + } + + @Override + public InternalRow[] rows() { + return rows; + } + + @Override + public StructType readSchema() { + return aggregateSchema; + } + + @Override + public String description() { + String aggregates = + Arrays.stream(aggregateSchema.fields()) + .map(StructField::name) + .collect(Collectors.joining(", ")); + return String.format("%s [aggregates=%s]", table, aggregates); Review Comment: It's a little strange that this class is generic and holds a set of rows, but then assumes that those rows are aggregates. Can you refactor this to be purely generic? -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org