cloud-fan commented on code in PR #50839: URL: https://github.com/apache/spark/pull/50839#discussion_r2087398670
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/AlterTableExec.scala: ########## @@ -44,3 +45,34 @@ case class AlterTableExec( Seq.empty } } + +/** + * Physical plan node for adding a check constraint with validation. + */ +case class AddCheckConstraintExec( + catalog: TableCatalog, + ident: Identifier, + changes: Seq[TableChange], + condition: String, + child: SparkPlan) extends V2CommandExec with UnaryExecNode { + + override def output: Seq[Attribute] = Seq.empty + + override protected def run(): Seq[InternalRow] = { + try { + if (child.executeTake(1).nonEmpty) { + throw QueryExecutionErrors.newCheckViolation(condition, ident.name()) Review Comment: shall we report the qualified name in the error message? it should be `ident.toQualifiedNameParts(catalog)` (need to import `CatalogV2Implicits`), and in `def newCheckViolation`, we call `toSqlId` to generate qualified table name from `Seq[String]` -- 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