tomvanbussel commented on code in PR #36936:
URL: https://github.com/apache/spark/pull/36936#discussion_r908106880
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/identifiers.scala:
##########
@@ -33,15 +36,34 @@ sealed trait IdentifierWithDatabase {
*/
private def quoteIdentifier(name: String): String = name.replace("`", "``")
- def quotedString: String = {
- val replacedId = quoteIdentifier(identifier)
- val replacedDb = database.map(quoteIdentifier(_))
+ def quotedString: String = quotedString(None)
+ def quotedString(catalog: String): String = quotedString(Some(catalog))
- if (replacedDb.isDefined) s"`${replacedDb.get}`.`$replacedId`" else
s"`$replacedId`"
+ def quotedString(catalog: Option[String]): String = {
Review Comment:
I don't think we should add these new methods. These methods make it easier
to omit the catalog than to include it. I'm worried that this leads to most new
code (and some existing code) not including the catalog. AFAIK it's always safe
to include the catalog name if the database name is set (as in that case we
know that it won't be a local temporary view), so the following should work:
```scala
def quotedString: String = {
val replacedId = quoteIdentifier(identifier)
val replacedDb = database.map(quoteIdentifier)
if (database.isDefined) {
if (SQLConf.get.getConf(LEGACY_NON_IDENTIFIER_OUTPUT_CATALOG_NAME) ||
isTempView) {
s"`${replacedDb.get}`.`$replacedId`"
} else {
s"`$SESSION_CATALOG_NAME`.`${replacedDb.get}`.`$replacedId`"
}
} else {
s"`$replacedId`"
}
}
--
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]