aokolnychyi commented on a change in pull request #1890:
URL: https://github.com/apache/iceberg/pull/1890#discussion_r538621508



##########
File path: 
spark3/src/main/java/org/apache/iceberg/spark/procedures/BaseProcedure.java
##########
@@ -75,25 +71,15 @@ protected BaseProcedure(TableCatalog tableCatalog) {
   }
 
   // we have to parse both namespace and name as they may be quoted
-  protected Identifier toIdentifier(String namespaceAsString, String name) {
-    String[] namespaceParts = parseMultipartIdentifier(namespaceAsString);
-
-    String[] nameParts = parseMultipartIdentifier(name);
-    Preconditions.checkArgument(nameParts.length == 1, "Name must consist of 
one part: %s", name);
-
-    return Identifier.of(namespaceParts, nameParts[0]);
-  }
-
-  private String[] parseMultipartIdentifier(String identifierAsString) {
+  protected Identifier toIdentifier(String identifier) {
+    Spark3Util.CatalogAndIdentifier catalogAndIdentifier;
     try {
-      ParserInterface parser = spark.sessionState().sqlParser();
-      Seq<String> namePartsSeq = 
parser.parseMultipartIdentifier(identifierAsString);
-      String[] nameParts = new String[namePartsSeq.size()];
-      namePartsSeq.copyToArray(nameParts);
-      return nameParts;
+      catalogAndIdentifier = Spark3Util.catalogAndIdentifier(spark, 
identifier, tableCatalog);

Review comment:
       Last time we talked, we thought about defaulting the catalog to the 
procedure catalog, not the default catalog.
   
   I thought we would simply take the first parsed name part and check if 
`spark.sql.catalog._name_part_` is set. If yes, it means our identifier 
contains a catalog and we don't have to prepend the procedure catalog to name 
parts and should resolve the catalog and validate the resolved catalog matches 
tableCatalog. If there is no such catalog, we can just call `tableCatalog.load` 
with the constructed identifier.
   




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

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