cloud-fan commented on code in PR #53530:
URL: https://github.com/apache/spark/pull/53530#discussion_r2646483766


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala:
##########
@@ -1927,6 +1927,70 @@ case class SetVariable(
     copy(sourceQuery = newChild)
 }
 
+/**
+ * The logical plan of the DECLARE CURSOR command.
+ * Note: The query child should not be fully analyzed/optimized at declaration 
time
+ * because we need to re-analyze it each time the cursor is opened to see fresh
+ * data.
+ */
+/**
+ * The logical plan of the DECLARE CURSOR statement.
+ *
+ * @param cursorName Name of the cursor
+ * @param query The parsed logical plan of the cursor query
+ * @param queryText The original SQL text of the query (preserves parameter 
markers)
+ * @param asensitive Whether the cursor is ASENSITIVE or INSENSITIVE
+ */
+case class DeclareCursor(
+    cursorName: String,
+    query: LogicalPlan,
+    queryText: String,
+    asensitive: Boolean = true) extends UnaryCommand {
+  override def child: LogicalPlan = query
+  override protected def withNewChildInternal(newChild: LogicalPlan): 
LogicalPlan =
+    copy(query = newChild)
+
+  // Mark that the child query should not be eagerly analyzed
+  override lazy val resolved: Boolean = cursorName.nonEmpty
+}
+
+/**
+ * The logical plan of the OPEN cursor command.
+ *
+ * @param cursorName Name of the cursor to open
+ * @param args Parameter expressions from USING clause
+ * @param paramNames Names for each parameter (empty string for positional 
parameters)
+ */
+case class OpenCursor(
+    cursorName: String,
+    args: Seq[Expression] = Seq.empty,
+    paramNames: Seq[String] = Seq.empty) extends Command {

Review Comment:
   we can extend `LeafCommand`



-- 
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]

Reply via email to