@@ -656,18 +656,19 @@ ProcessCreateIcebergTableFromForeignTableStmt(ProcessUtilityParams * params)
656656
657657 bool hasRestCatalogOption = HasRestCatalogTableOption (createStmt -> options );
658658 bool hasObjectStoreCatalogOption = HasObjectStoreCatalogTableOption (createStmt -> options );
659- bool hasExternalCatalogReadOnlyOption = HasReadOnlyOption (createStmt -> options );
660659
661- /*
662- * Read-only external catalog tables are a special case of Iceberg tables.
663- * They are recognized as Iceberg tables, but are not registered in any
664- * internal catalogs (e.g., lake_iceberg.tables). Instead, the table is
665- * created only in PostgreSQL’s system catalogs. When the table is
666- * queried, its metadata is fetched on demand from the external catalog.
667- */
668- if ((hasObjectStoreCatalogOption ||
669- (hasRestCatalogOption && hasExternalCatalogReadOnlyOption )))
660+ if (hasObjectStoreCatalogOption || hasRestCatalogOption )
670661 {
662+ /*
663+ * Read-only external catalog tables are a special case of Iceberg
664+ * tables. They are recognized as Iceberg tables, but are not
665+ * registered in any internal catalogs (e.g., lake_iceberg.tables).
666+ * Instead, the table is created only in PostgreSQL’s system
667+ * catalogs. When the table is queried, its metadata is fetched on
668+ * demand from the external catalog.
669+ */
670+ bool hasExternalCatalogReadOnlyOption = HasReadOnlyOption (createStmt -> options );
671+
671672 char * metadataLocation = NULL ;
672673 char * catalogNamespace = NULL ;
673674 char * catalogTableName = NULL ;
@@ -725,7 +726,7 @@ ProcessCreateIcebergTableFromForeignTableStmt(ProcessUtilityParams * params)
725726 catalogName = catalogNameProvided ;
726727 }
727728
728- if (hasRestCatalogOption )
729+ if (hasRestCatalogOption && hasExternalCatalogReadOnlyOption )
729730 {
730731 ErrorIfRestNamespaceDoesNotExist (catalogName , catalogNamespace );
731732
@@ -742,7 +743,7 @@ ProcessCreateIcebergTableFromForeignTableStmt(ProcessUtilityParams * params)
742743 catalogTableName );
743744 }
744745
745- if (hasObjectStoreCatalogOption && !hasExternalCatalogReadOnlyOption )
746+ if (!hasExternalCatalogReadOnlyOption )
746747 {
747748 /*
748749 * For writable object store catalog tables, we need to continue
@@ -757,11 +758,11 @@ ProcessCreateIcebergTableFromForeignTableStmt(ProcessUtilityParams * params)
757758 catalogNameProvided != NULL )
758759 {
759760 ereport (ERROR , (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
760- errmsg ("writable object store catalog iceberg tables do not "
761- "allow explicit catalog options" )));
761+ errmsg ("writable %s catalog iceberg tables do not "
762+ "allow explicit catalog options" , hasObjectStoreCatalogOption ? "object store" : "REST" )));
762763 }
763764 }
764- else if (createStmt -> base .tableElts == NIL )
765+ else if (createStmt -> base .tableElts == NIL && hasExternalCatalogReadOnlyOption )
765766 {
766767 List * dataFileColumns =
767768 DescribeColumnsFromIcebergMetadataURI (metadataLocation , false);
0 commit comments