viirya commented on code in PR #50584: URL: https://github.com/apache/spark/pull/50584#discussion_r2047991083
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/constraints.scala: ########## @@ -18,56 +18,80 @@ package org.apache.spark.sql.catalyst.expressions import java.util.UUID -import org.antlr.v4.runtime.ParserRuleContext - import org.apache.spark.sql.catalyst.parser.ParseException +import org.apache.spark.sql.catalyst.trees.CurrentOrigin import org.apache.spark.sql.types.{DataType, StringType} trait TableConstraint { - /** Returns the name of the constraint */ - def name: String + /** Returns the user-provided name of the constraint */ + def userProvidedName: String + + /** Returns the name of the table containing this constraint */ + def tableName: String - /** Returns the characteristics of the constraint (e.g., ENFORCED, RELY) */ - def characteristic: ConstraintCharacteristic + /** Returns the user-provided characteristics of the constraint (e.g., ENFORCED, RELY) */ + def userProvidedCharacteristic: ConstraintCharacteristic - /** Creates a new constraint with the given name + /** Creates a new constraint with the user-provided name * * @param name Constraint name * @return New TableConstraint instance */ - def withName(name: String): TableConstraint + def withUserProvidedName(name: String): TableConstraint - /** Creates a new constraint with the given characteristic + /** + * Creates a new constraint with the given table name + * + * @param tableName Name of the table containing this constraint + * @return New TableConstraint instance + */ + def withTableName(tableName: String): TableConstraint + + /** Creates a new constraint with the user-provided characteristic * * @param c Constraint characteristic (ENFORCED, RELY) - * @param ctx Parser context for error reporting * @return New TableConstraint instance */ - def withCharacteristic(c: ConstraintCharacteristic, ctx: ParserRuleContext): TableConstraint + def withUserProvidedCharacteristic(c: ConstraintCharacteristic): TableConstraint // Generate a constraint name based on the table name if the name is not specified - protected def generateConstraintName(tableName: String): String + protected def generateName(tableName: String): String - /** Generates a constraint name if one is not provided + /** + * Gets the constraint name. If no name is specified (null or empty), + * generates a name based on the table name using generateConstraintName. Review Comment: ```suggestion * generates a name based on the table name using generateName. ``` -- 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