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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/SqlScriptingLogicalPlans.scala:
##########
@@ -298,3 +306,93 @@ case class ForStatement(
       ForStatement(query, variableName, body, label)
   }
 }
+
+/**
+ * Logical operator for an error condition.
+ * @param conditionName Name of the error condition.
+ * @param sqlState SQLSTATE or Error Code.
+ */
+case class ErrorCondition(
+    conditionName: String,
+    sqlState: String) extends CompoundPlanStatement {
+  override def output: Seq[Attribute] = Seq.empty
+
+  override def children: Seq[LogicalPlan] = Seq.empty
+
+  override protected def withNewChildrenInternal(
+      newChildren: IndexedSeq[LogicalPlan]): LogicalPlan = this.copy()
+}
+
+object HandlerType extends Enumeration {
+  type HandlerType = Value
+  val EXIT, CONTINUE = Value
+}
+
+/**
+ * Class holding information about what triggers the handler.
+ * @param sqlStates Name of the error condition.
+ * @param conditions SQLSTATE or Error Code.
+ * @param sqlException Flag indicating if the handler is triggered by 
SQLEXCEPTION.
+ * @param notFound Flag indicating if the handler is triggered by NOT FOUND.
+ */
+class HandlerTriggers(
+    val sqlStates: Set[String] = Set.empty,
+    val conditions: Set[String] = Set.empty,
+    var sqlException: Boolean = false,
+    var notFound: Boolean = false) {
+
+  def addUniqueSqlException(): Unit = {
+    if (sqlException) {
+      throw SqlScriptingErrors
+        .duplicateConditionInHandlerDeclaration(CurrentOrigin.get, 
"SQLEXCEPTION")
+    }
+    sqlException = true
+  }
+
+  def addUniqueNotFound(): Unit = {
+    if (notFound) {
+      throw SqlScriptingErrors
+        .duplicateConditionInHandlerDeclaration(CurrentOrigin.get, "NOT FOUND")
+    }
+    notFound = true
+  }
+
+  def addUniqueCondition(value: String): Unit = {
+    if (conditions.contains(value)) {

Review Comment:
   ditto, case sensitivity?



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