cloud-fan commented on code in PR #53530: URL: https://github.com/apache/spark/pull/53530#discussion_r2685372945
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CursorReference.scala: ########## @@ -0,0 +1,67 @@ +/* + * 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.expressions + +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.catalyst.analysis.UnresolvedException +import org.apache.spark.sql.catalyst.trees.TreePattern.{CURSOR_REFERENCE, TreePattern => TP, UNRESOLVED_CURSOR} +import org.apache.spark.sql.types.DataType + +/** + * An unresolved reference to a cursor. This is used during parsing and will be resolved + * to a [[CursorReference]] by the [[ResolveCursors]] analyzer rule. + * + * @param nameParts The parts of the cursor name (e.g., Seq("cursor") or Seq("label", "cursor")) + */ +case class UnresolvedCursor(nameParts: Seq[String]) extends LeafExpression with Unevaluable { + override def dataType: DataType = throw new UnresolvedException("dataType") + override def nullable: Boolean = throw new UnresolvedException("nullable") + override lazy val resolved: Boolean = false + override def sql: String = nameParts.mkString(".") + override def toString: String = s"UnresolvedCursor(${nameParts.mkString(".")})" + + final override val nodePatterns: Seq[TP] = Seq(UNRESOLVED_CURSOR) +} + +/** + * A resolved reference to a cursor. This is created by the [[ResolveCursors]] analyzer rule + * after normalizing the cursor name parts, checking case sensitivity, and looking up the + * cursor definition from the scripting context. + * + * @param nameParts The original cursor name parts (unnormalized) + * @param normalizedName The normalized cursor name (for lookups considering case sensitivity) + * @param scopeLabel Optional label qualifier for scoped cursors (e.g., Some("label") for + * "label.cursor", None for unqualified cursors) + * @param definition The cursor definition looked up during analysis. Type is Any to avoid + * circular dependency (catalyst cannot import sql/core classes). At runtime, + * this will be cast to CursorDefinition. + */ +case class CursorReference( + nameParts: Seq[String], + normalizedName: String, + scopeLabel: Option[String], + definition: Any) extends LeafExpression with Unevaluable { Review Comment: shall we put `CursorDefinition` in this file? It's just two string fields -- 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]
