cloud-fan commented on code in PR #51705: URL: https://github.com/apache/spark/pull/51705#discussion_r2258840896
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/VariableManager.scala: ########## @@ -81,6 +81,47 @@ trait VariableManager { * @return true if at least one variable exists, false otherwise. */ def isEmpty: Boolean + + /** + * + * @param variableName Name of the variable + * @return variable name formatting for the error + */ + protected def getVariableNameForError(variableName: String): String + + /** + * Create a variable. + * @param variables Variables to be created, + * a list of tuples of nameParts and varDef for each variable + * @param overrideIfExists If true, the new variable will replace an existing one + * with the same identifier, if it exists. + */ + final def create( + variables: Seq[(Seq[String], VariableDefinition)], + overrideIfExists: Boolean): Unit = synchronized { + if (!overrideIfExists) { + val uniqueNames = mutable.Set[String]() + + variables.foreach(variable => { + val nameParts: Seq[String] = variable._1 + val name = nameParts.last + if (get(nameParts).isDefined || uniqueNames.contains(name)) { Review Comment: do we need to consider case sensitivity? do we have tests for it? -- 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