nastra commented on code in PR #9675:
URL: https://github.com/apache/iceberg/pull/9675#discussion_r1501376695
##########
spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteViewCommands.scala:
##########
@@ -102,20 +113,23 @@ case class RewriteViewCommands(spark: SparkSession)
extends Rule[LogicalPlan] wi
private def verifyTemporaryObjectsDontExist(
name: Identifier,
child: LogicalPlan): Unit = {
- import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
-
val tempViews = collectTemporaryViews(child)
- tempViews.foreach { nameParts =>
- throw new AnalysisException(
- errorClass = "INVALID_TEMP_OBJ_REFERENCE",
- messageParameters = Map(
- "obj" -> "VIEW",
- "objName" -> name.name(),
- "tempObj" -> "VIEW",
- "tempObjName" -> nameParts.quoted))
+ if (tempViews.nonEmpty) {
+ throw invalidRefToTempObject(name, tempViews.map(v =>
v.quoted).mkString("[", ", ", "]"), "VIEW")
}
- // TODO: check for temp function names
+ val tempFunctions = collectTemporaryFunctions(child)
+ if (tempFunctions.nonEmpty) {
+ throw invalidRefToTempObject(name, tempFunctions.mkString("[", ", ",
"]"), "FUNCTION")
Review Comment:
I don't think it would be correc to include the catalog name, because temp
functions don't belong to any catalog. This can also be seen in the above
example:
```
spark-sql ()> use sandbox;
Time taken: 0.013 seconds
spark-sql ()> CREATE TEMPORARY FUNCTION temp_function AS
'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage';
Time taken: 0.012 seconds
spark-sql ()> show user functions;
sandbox.bucket
sandbox.days
sandbox.hours
sandbox.iceberg_version
sandbox.months
sandbox.truncate
sandbox.years
temp_function
Time taken: 0.028 seconds, Fetched 9 row(s)
spark-sql ()> use spark_catalog;
Time taken: 0.015 seconds
spark-sql (default)> show user functions;
temp_function
Time taken: 0.045 seconds, Fetched 3 row(s)
```
--
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]