dtenedor commented on code in PR #53941:
URL: https://github.com/apache/spark/pull/53941#discussion_r2737954948


##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/SqlGraphRegistrationContext.scala:
##########
@@ -529,8 +532,12 @@ class SqlGraphRegistrationContext(
   }
 
   private object SetCatalogCommandHandler {
-    def handle(setCatalogCommand: SetCatalogCommand): Unit = {
-      context.setCurrentCatalog(setCatalogCommand.catalogName)
+    def handle(setCatalogCommand: SetCatalogCommand, spark: SparkSession): 
Unit = {
+      // Analyze unresolved references in the expression of the SET CATALOG 
command.
+      // before handling the command.
+      val analyzedSetCatalogCommand = 
spark.sessionState.analyzer.execute(setCatalogCommand)
+        .asInstanceOf[SetCatalogCommand]

Review Comment:
   And we could test it with something like:
   
   ```
   test("SET CATALOG with analysis error") {
       val graphRegistrationContext = new TestGraphRegistrationContext(spark)
       val sqlGraphRegistrationContext = new 
SqlGraphRegistrationContext(graphRegistrationContext)
   
       val ex = intercept[SqlGraphElementRegistrationException] {
         sqlGraphRegistrationContext.processSqlFile(
           sqlText = "SET CATALOG 42",
           sqlFilePath = "a.sql",
           spark = spark
         )
       }
   
       checkError(ex, ...)
     }
   ```



-- 
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]

Reply via email to