Skip to content

Commit f76e3c3

Browse files
committed
Remove iceberg.rest-catalog.parent-namespace property
The property was added for supporting Unity catalog. They changed the behavior to respect warehouse property in unitycatalog/unitycatalog#324.
1 parent 92c58a8 commit f76e3c3

File tree

7 files changed

+7
-46
lines changed

7 files changed

+7
-46
lines changed

docs/src/main/sphinx/object-storage/metastores.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ following properties:
484484
* - `iceberg.rest-catalog.warehouse`
485485
- Warehouse identifier/location for the catalog (optional). Example:
486486
`s3://my_bucket/warehouse_location`
487-
* - `iceberg.rest-catalog.parent-namespace`
488-
- The namespace to use with the REST catalog server. Example:
489-
`main`
490487
* - `iceberg.rest-catalog.security`
491488
- The type of security to use (default: `NONE`). `OAUTH2` requires either a
492489
`token` or `credential`. Example: `OAUTH2`
@@ -537,7 +534,6 @@ iceberg.rest-catalog.uri=https://dbc-12345678-9999.cloud.databricks.com/api/2.1/
537534
iceberg.security=read_only
538535
iceberg.rest-catalog.security=OAUTH2
539536
iceberg.rest-catalog.oauth2.token=***
540-
iceberg.rest-catalog.parent-namespace=test_namespace
541537
```
542538

543539
The REST catalog supports [view management](sql-view-management)

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/IcebergRestCatalogConfig.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515

1616
import io.airlift.configuration.Config;
1717
import io.airlift.configuration.ConfigDescription;
18+
import io.airlift.configuration.DefunctConfig;
1819
import io.airlift.units.Duration;
1920
import io.airlift.units.MinDuration;
2021
import jakarta.validation.constraints.NotNull;
21-
import org.apache.iceberg.catalog.Namespace;
2222

2323
import java.net.URI;
2424
import java.util.Optional;
2525

2626
import static java.util.concurrent.TimeUnit.MINUTES;
2727

28+
@DefunctConfig("iceberg.rest-catalog.parent-namespace")
2829
public class IcebergRestCatalogConfig
2930
{
3031
public enum Security
@@ -42,7 +43,6 @@ public enum SessionType
4243
private URI restUri;
4344
private Optional<String> prefix = Optional.empty();
4445
private Optional<String> warehouse = Optional.empty();
45-
private Namespace parentNamespace = Namespace.of();
4646
private boolean nestedNamespaceEnabled;
4747
private Security security = Security.NONE;
4848
private SessionType sessionType = SessionType.NONE;
@@ -92,19 +92,6 @@ public IcebergRestCatalogConfig setWarehouse(String warehouse)
9292
return this;
9393
}
9494

95-
public Namespace getParentNamespace()
96-
{
97-
return parentNamespace;
98-
}
99-
100-
@Config("iceberg.rest-catalog.parent-namespace")
101-
@ConfigDescription("The parent namespace to use with the REST catalog server")
102-
public IcebergRestCatalogConfig setParentNamespace(String parentNamespace)
103-
{
104-
this.parentNamespace = parentNamespace == null ? Namespace.empty() : Namespace.of(parentNamespace);
105-
return this;
106-
}
107-
10895
public boolean isNestedNamespaceEnabled()
10996
{
11097
return nestedNamespaceEnabled;

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoIcebergRestCatalogFactory.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class TrinoIcebergRestCatalogFactory
5454
private final URI serverUri;
5555
private final Optional<String> prefix;
5656
private final Optional<String> warehouse;
57-
private final Namespace parentNamespace;
5857
private final boolean nestedNamespaceEnabled;
5958
private final SessionType sessionType;
6059
private final boolean vendedCredentialsEnabled;
@@ -85,7 +84,6 @@ public TrinoIcebergRestCatalogFactory(
8584
this.serverUri = restConfig.getBaseUri();
8685
this.prefix = restConfig.getPrefix();
8786
this.warehouse = restConfig.getWarehouse();
88-
this.parentNamespace = restConfig.getParentNamespace();
8987
this.nestedNamespaceEnabled = restConfig.isNestedNamespaceEnabled();
9088
this.sessionType = restConfig.getSessionType();
9189
this.vendedCredentialsEnabled = restConfig.isVendedCredentialsEnabled();
@@ -144,7 +142,6 @@ public synchronized TrinoCatalog create(ConnectorIdentity identity)
144142
catalogName,
145143
sessionType,
146144
credentials,
147-
parentNamespace,
148145
nestedNamespaceEnabled,
149146
trinoVersion,
150147
typeManager,

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoRestCatalog.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
import static java.util.Locale.ENGLISH;
9898
import static java.util.Objects.requireNonNull;
9999
import static java.util.UUID.randomUUID;
100-
import static java.util.stream.Collectors.joining;
101100
import static org.apache.iceberg.view.ViewProperties.COMMENT;
102101

103102
public class TrinoRestCatalog
@@ -113,7 +112,6 @@ public class TrinoRestCatalog
113112
private final TypeManager typeManager;
114113
private final SessionType sessionType;
115114
private final Map<String, String> credentials;
116-
private final Namespace parentNamespace;
117115
private final boolean nestedNamespaceEnabled;
118116
private final String trinoVersion;
119117
private final boolean useUniqueTableLocation;
@@ -130,7 +128,6 @@ public TrinoRestCatalog(
130128
CatalogName catalogName,
131129
SessionType sessionType,
132130
Map<String, String> credentials,
133-
Namespace parentNamespace,
134131
boolean nestedNamespaceEnabled,
135132
String trinoVersion,
136133
TypeManager typeManager,
@@ -143,7 +140,6 @@ public TrinoRestCatalog(
143140
this.catalogName = requireNonNull(catalogName, "catalogName is null");
144141
this.sessionType = requireNonNull(sessionType, "sessionType is null");
145142
this.credentials = ImmutableMap.copyOf(requireNonNull(credentials, "credentials is null"));
146-
this.parentNamespace = requireNonNull(parentNamespace, "parentNamespace is null");
147143
this.nestedNamespaceEnabled = nestedNamespaceEnabled;
148144
this.trinoVersion = requireNonNull(trinoVersion, "trinoVersion is null");
149145
this.typeManager = requireNonNull(typeManager, "typeManager is null");
@@ -169,9 +165,9 @@ public boolean namespaceExists(ConnectorSession session, String namespace)
169165
public List<String> listNamespaces(ConnectorSession session)
170166
{
171167
if (nestedNamespaceEnabled) {
172-
return collectNamespaces(session, parentNamespace);
168+
return collectNamespaces(session, Namespace.empty());
173169
}
174-
return restSessionCatalog.listNamespaces(convert(session), parentNamespace).stream()
170+
return restSessionCatalog.listNamespaces(convert(session)).stream()
175171
.map(this::toSchemaName)
176172
.collect(toImmutableList());
177173
}
@@ -732,25 +728,15 @@ private Namespace toNamespace(String schemaName)
732728
if (!nestedNamespaceEnabled && schemaName.contains(NAMESPACE_SEPARATOR)) {
733729
throw new TrinoException(NOT_SUPPORTED, "Nested namespace is not enabled for this catalog");
734730
}
735-
if (!parentNamespace.isEmpty()) {
736-
schemaName = parentNamespace + NAMESPACE_SEPARATOR + schemaName;
737-
}
738731
return Namespace.of(Splitter.on(NAMESPACE_SEPARATOR).omitEmptyStrings().trimResults().splitToList(schemaName).toArray(new String[0]));
739732
}
740733

741734
private String toSchemaName(Namespace namespace)
742735
{
743-
if (this.parentNamespace.isEmpty()) {
744-
if (!nestedNamespaceEnabled && namespace.length() != 1) {
745-
throw new TrinoException(NOT_SUPPORTED, "Nested namespace is not enabled for this catalog");
746-
}
747-
return namespace.toString();
748-
}
749-
if (!nestedNamespaceEnabled && ((namespace.length() - parentNamespace.length()) > 1)) {
736+
if (!nestedNamespaceEnabled && namespace.length() != 1) {
750737
throw new TrinoException(NOT_SUPPORTED, "Nested namespace is not enabled for this catalog");
751738
}
752-
return Arrays.stream(namespace.levels(), this.parentNamespace.length(), namespace.length())
753-
.collect(joining(NAMESPACE_SEPARATOR));
739+
return String.join(NAMESPACE_SEPARATOR, namespace.levels());
754740
}
755741

756742
private TableIdentifier toIdentifier(SchemaTableName schemaTableName)

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/IcebergQueryRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public static void main(String[] args)
259259
.addIcebergProperty("iceberg.security", "read_only")
260260
.addIcebergProperty("iceberg.catalog.type", "rest")
261261
.addIcebergProperty("iceberg.rest-catalog.uri", unityCatalog.uri() + "/iceberg")
262-
.addIcebergProperty("iceberg.rest-catalog.parent-namespace", "unity")
262+
.addIcebergProperty("iceberg.rest-catalog.warehouse", "unity")
263263
.addIcebergProperty("iceberg.register-table-procedure.enabled", "true")
264264
.disableSchemaInitializer()
265265
.build();

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergRestCatalogConfig.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void testDefaults()
3333
.setBaseUri(null)
3434
.setPrefix(null)
3535
.setWarehouse(null)
36-
.setParentNamespace(null)
3736
.setNestedNamespaceEnabled(false)
3837
.setSessionType(IcebergRestCatalogConfig.SessionType.NONE)
3938
.setSecurity(IcebergRestCatalogConfig.Security.NONE)
@@ -49,7 +48,6 @@ public void testExplicitPropertyMappings()
4948
.put("iceberg.rest-catalog.uri", "http://localhost:1234")
5049
.put("iceberg.rest-catalog.prefix", "dev")
5150
.put("iceberg.rest-catalog.warehouse", "test_warehouse_identifier")
52-
.put("iceberg.rest-catalog.parent-namespace", "main")
5351
.put("iceberg.rest-catalog.nested-namespace-enabled", "true")
5452
.put("iceberg.rest-catalog.security", "OAUTH2")
5553
.put("iceberg.rest-catalog.session", "USER")
@@ -62,7 +60,6 @@ public void testExplicitPropertyMappings()
6260
.setBaseUri("http://localhost:1234")
6361
.setPrefix("dev")
6462
.setWarehouse("test_warehouse_identifier")
65-
.setParentNamespace("main")
6663
.setNestedNamespaceEnabled(true)
6764
.setSessionType(IcebergRestCatalogConfig.SessionType.USER)
6865
.setSecurity(IcebergRestCatalogConfig.Security.OAUTH2)

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestTrinoRestCatalog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import io.trino.spi.security.TrinoPrincipal;
3434
import io.trino.spi.type.TestingTypeManager;
3535
import io.trino.spi.type.VarcharType;
36-
import org.apache.iceberg.catalog.Namespace;
3736
import org.apache.iceberg.exceptions.BadRequestException;
3837
import org.apache.iceberg.rest.DelegatingRestSessionCatalog;
3938
import org.apache.iceberg.rest.RESTSessionCatalog;
@@ -87,7 +86,6 @@ private static TrinoRestCatalog createTrinoRestCatalog(boolean useUniqueTableLoc
8786
new CatalogName(catalogName),
8887
NONE,
8988
ImmutableMap.of(),
90-
Namespace.empty(),
9189
false,
9290
"test",
9391
new TestingTypeManager(),

0 commit comments

Comments
 (0)