@@ -167,6 +167,11 @@ public Catalog paimonCatalog() {
167167 return catalog ;
168168 }
169169
170+ @ Override
171+ public String paimonCatalogName () {
172+ return catalogName ;
173+ }
174+
170175 // ======================= database methods ===============================
171176
172177 @ Override
@@ -177,7 +182,7 @@ public String[] defaultNamespace() {
177182 @ Override
178183 public void createNamespace (String [] namespace , Map <String , String > metadata )
179184 throws NamespaceAlreadyExistsException {
180- checkNamespace (namespace );
185+ checkNamespace (namespace , catalogName );
181186 try {
182187 String databaseName = getDatabaseNameFromNamespace (namespace );
183188 catalog .createDatabase (databaseName , false , metadata );
@@ -201,7 +206,7 @@ public String[][] listNamespaces(String[] namespace) throws NoSuchNamespaceExcep
201206 if (namespace .length == 0 ) {
202207 return listNamespaces ();
203208 }
204- checkNamespace (namespace );
209+ checkNamespace (namespace , catalogName );
205210 try {
206211 String databaseName = getDatabaseNameFromNamespace (namespace );
207212 catalog .getDatabase (databaseName );
@@ -214,7 +219,7 @@ public String[][] listNamespaces(String[] namespace) throws NoSuchNamespaceExcep
214219 @ Override
215220 public Map <String , String > loadNamespaceMetadata (String [] namespace )
216221 throws NoSuchNamespaceException {
217- checkNamespace (namespace );
222+ checkNamespace (namespace , catalogName );
218223 try {
219224 String databaseName = getDatabaseNameFromNamespace (namespace );
220225 return catalog .getDatabase (databaseName ).options ();
@@ -252,7 +257,7 @@ public boolean dropNamespace(String[] namespace) throws NoSuchNamespaceException
252257 */
253258 public boolean dropNamespace (String [] namespace , boolean cascade )
254259 throws NoSuchNamespaceException {
255- checkNamespace (namespace );
260+ checkNamespace (namespace , catalogName );
256261 try {
257262 String databaseName = getDatabaseNameFromNamespace (namespace );
258263 catalog .dropDatabase (databaseName , false , cascade );
@@ -268,7 +273,7 @@ public boolean dropNamespace(String[] namespace, boolean cascade)
268273 @ Override
269274 public void alterNamespace (String [] namespace , NamespaceChange ... changes )
270275 throws NoSuchNamespaceException {
271- checkNamespace (namespace );
276+ checkNamespace (namespace , catalogName );
272277 try {
273278 String databaseName = getDatabaseNameFromNamespace (namespace );
274279 List <PropertyChange > propertyChanges =
@@ -283,7 +288,7 @@ public void alterNamespace(String[] namespace, NamespaceChange... changes)
283288
284289 @ Override
285290 public Identifier [] listTables (String [] namespace ) throws NoSuchNamespaceException {
286- checkNamespace (namespace );
291+ checkNamespace (namespace , catalogName );
287292 try {
288293 String databaseName = getDatabaseNameFromNamespace (namespace );
289294 return catalog .listTables (databaseName ).stream ()
@@ -296,7 +301,7 @@ public Identifier[] listTables(String[] namespace) throws NoSuchNamespaceExcepti
296301
297302 @ Override
298303 public void invalidateTable (Identifier ident ) {
299- catalog .invalidateTable (toIdentifier (ident ));
304+ catalog .invalidateTable (toIdentifier (ident , catalogName ));
300305 }
301306
302307 @ Override
@@ -349,7 +354,7 @@ public org.apache.spark.sql.connector.catalog.Table alterTable(
349354 List <SchemaChange > schemaChanges =
350355 Arrays .stream (changes ).map (this ::toSchemaChange ).collect (Collectors .toList ());
351356 try {
352- catalog .alterTable (toIdentifier (ident ), schemaChanges , false );
357+ catalog .alterTable (toIdentifier (ident , catalogName ), schemaChanges , false );
353358 return loadTable (ident );
354359 } catch (Catalog .TableNotExistException e ) {
355360 throw new NoSuchTableException (ident );
@@ -367,7 +372,9 @@ public org.apache.spark.sql.connector.catalog.Table createTable(
367372 throws TableAlreadyExistsException , NoSuchNamespaceException {
368373 try {
369374 catalog .createTable (
370- toIdentifier (ident ), toInitialSchema (schema , partitions , properties ), false );
375+ toIdentifier (ident , catalogName ),
376+ toInitialSchema (schema , partitions , properties ),
377+ false );
371378 return loadTable (ident );
372379 } catch (Catalog .TableAlreadyExistException e ) {
373380 throw new TableAlreadyExistsException (ident );
@@ -381,7 +388,7 @@ public org.apache.spark.sql.connector.catalog.Table createTable(
381388 @ Override
382389 public boolean dropTable (Identifier ident ) {
383390 try {
384- catalog .dropTable (toIdentifier (ident ), false );
391+ catalog .dropTable (toIdentifier (ident , catalogName ), false );
385392 return true ;
386393 } catch (Catalog .TableNotExistException e ) {
387394 return false ;
@@ -524,8 +531,8 @@ public void renameTable(Identifier oldIdent, Identifier newIdent)
524531 throws NoSuchTableException , TableAlreadyExistsException {
525532 try {
526533 catalog .renameTable (
527- toIdentifier (oldIdent ),
528- toIdentifier (removeCatalogName (newIdent , catalogName )),
534+ toIdentifier (oldIdent , catalogName ),
535+ toIdentifier (removeCatalogName (newIdent , catalogName ), catalogName ),
529536 false );
530537 } catch (Catalog .TableNotExistException e ) {
531538 throw new NoSuchTableException (oldIdent );
@@ -566,7 +573,7 @@ public UnboundFunction loadFunction(Identifier ident) throws NoSuchFunctionExcep
566573 }
567574 } else if (isDatabaseFunctionNamespace (namespace )) {
568575 try {
569- Function paimonFunction = catalog .getFunction (toIdentifier (ident ));
576+ Function paimonFunction = catalog .getFunction (toIdentifier (ident , catalogName ));
570577 FunctionDefinition functionDefinition =
571578 paimonFunction .definition (FUNCTION_DEFINITION_NAME );
572579 if (functionDefinition instanceof FunctionDefinition .LambdaFunctionDefinition ) {
@@ -654,13 +661,17 @@ public void dropV1Function(FunctionIdentifier funcIdent, boolean ifExists) throw
654661 protected org .apache .spark .sql .connector .catalog .Table loadSparkTable (
655662 Identifier ident , Map <String , String > extraOptions ) throws NoSuchTableException {
656663 try {
657- org .apache .paimon .table .Table paimonTable = catalog .getTable (toIdentifier (ident ));
664+ org .apache .paimon .table .Table paimonTable =
665+ catalog .getTable (toIdentifier (ident , catalogName ));
658666 if (paimonTable instanceof FormatTable ) {
659667 return toSparkFormatTable (ident , (FormatTable ) paimonTable );
660668 } else {
661669 return new SparkTable (
662670 copyWithSQLConf (
663- paimonTable , catalogName , toIdentifier (ident ), extraOptions ));
671+ paimonTable ,
672+ catalogName ,
673+ toIdentifier (ident , catalogName ),
674+ extraOptions ));
664675 }
665676 } catch (Catalog .TableNotExistException e ) {
666677 throw new NoSuchTableException (ident );
0 commit comments