aokolnychyi commented on code in PR #50584: URL: https://github.com/apache/spark/pull/50584#discussion_r2045535723
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/constraints.scala: ########## @@ -38,36 +40,59 @@ trait TableConstraint { */ def withName(name: String): TableConstraint + /** + * 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 given 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 withCharacteristic(c: ConstraintCharacteristic): TableConstraint // Generate a constraint name based on the table name if the name is not specified protected def generateConstraintName(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. * - * @param tableName Name of the table containing this constraint - * @return TableConstraint with a generated name if original name was null/empty + * @return The constraint name (either user-specified or generated) */ - def generateConstraintNameIfNeeded(tableName: String): TableConstraint = { + final def constraintName: String = { Review Comment: I am still not convinced it is a good idea to have both `name` and `constraintName`. It seems fragile and unclear. Whoever uses this class will have to know the subtle difference between the methods. I find it reasonable to expect the caller to generate the name and keep this class as a container. I'd be curious to hear what other folks think as well. I am not going to insist on it. It is an internal API. -- 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