aakash-db commented on code in PR #51003: URL: https://github.com/apache/spark/pull/51003#discussion_r2114338119
########## sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/elements.scala: ########## @@ -0,0 +1,277 @@ +/* + * 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.pipelines.graph + +import java.util + +import scala.util.control.NonFatal + +import org.apache.spark.SparkException +import org.apache.spark.internal.Logging +import org.apache.spark.sql.Row +import org.apache.spark.sql.catalyst.TableIdentifier +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder +import org.apache.spark.sql.classic.{DataFrame, SparkSession} +import org.apache.spark.sql.execution.streaming.MemoryStream +import org.apache.spark.sql.pipelines.common.DatasetType +import org.apache.spark.sql.pipelines.util.{ + BatchReadOptions, + InputReadOptions, + SchemaInferenceUtils, + StreamingReadOptions +} +import org.apache.spark.sql.types.StructType + +/** An element in a [[DataflowGraph]]. */ +trait GraphElement { + + /** + * Contains provenance to tie back this GraphElement to the user code that defined it. + * + * This must be set when a [[GraphElement]] is directly created by some user code. + * Subsequently, this initial origin must be propagated as is without modification. + * If this [[GraphElement]] is copied or converted to a different type, then this origin must be + * copied as is. + */ + def origin: QueryOrigin + + protected def spark: SparkSession = SparkSession.getActiveSession.get + + /** Returns the unique identifier for this [[GraphElement]]. */ + def identifier: TableIdentifier + + /** + * Returns a user-visible name for the element. + */ + def displayName: String = identifier.unquotedString +} + +/** + * Specifies an input that can be referenced by another Dataset's query. + */ +trait Input extends GraphElement { + + /** + * Returns a [[DataFrame]] that is a result of loading data from this [[Input]]. + * @param readOptions Type of input. Used to determine streaming/batch + * @return Streaming or batch [[DataFrame]] of this Input's data. + */ + def load(readOptions: InputReadOptions): DataFrame +} + +/** Represents a node in a [[DataflowGraph]] that can be written to by a [[Flow]]. */ +sealed trait Output { + + /** + * Normalized storage location used for storing materializations for this [[Output]]. + * If [[None]], it means this [[Output]] has not been normalized yet. Review Comment: added a comment. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org