Skip to content

Commit 70f8ca4

Browse files
committed
Remove redundant code
1 parent 167459d commit 70f8ca4

File tree

9 files changed

+40
-95
lines changed

9 files changed

+40
-95
lines changed

polaris-core/src/main/java/io/polaris/core/storage/azure/AzureCredentialsStorageIntegration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public EnumMap<PolarisCredentialProperty, String> getSubscopedCreds(
8686
validateAccountAndContainer(location, allowedReadLocations, allowedWriteLocations);
8787

8888
String storageDnsName = location.getStorageAccount() + "." + location.getEndpoint();
89-
String endpoint = "https://" + storageDnsName;
9089
String filePath = location.getFilePath();
9190

9291
BlobSasPermission blobSasPermission = new BlobSasPermission();

polaris-core/src/test/java/io/polaris/service/storage/aws/AwsCredentialsStorageIntegrationTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@ public void testGetSubscopedCredsInlinePolicyWithEmptyReadAndWrite() {
381381
String externalId = "externalId";
382382
String bucket = "bucket";
383383
String warehouseKeyPrefix = "path/to/warehouse";
384-
String firstPath = warehouseKeyPrefix + "/namespace/table";
385-
String secondPath = warehouseKeyPrefix + "/oldnamespace/table";
386384
Mockito.when(stsClient.assumeRole(Mockito.isA(AssumeRoleRequest.class)))
387385
.thenAnswer(
388386
invocation -> {
@@ -449,14 +447,6 @@ public void testGetSubscopedCredsInlinePolicyWithEmptyReadAndWrite() {
449447
return bucketArn + "/" + keyPrefix + "/*";
450448
}
451449

452-
private static @NotNull String s3CnArn(String bucket, String keyPrefix) {
453-
String bucketArn = "arn:aws-cn:s3:::" + bucket;
454-
if (keyPrefix == null) {
455-
return bucketArn;
456-
}
457-
return bucketArn + "/" + keyPrefix + "/*";
458-
}
459-
460450
private static @NotNull String s3Path(
461451
String bucket, String keyPrefix, PolarisStorageConfigurationInfo.StorageType storageType) {
462452
return storageType.getPrefix() + bucket + "/" + keyPrefix;

polaris-service/src/main/java/io/polaris/service/auth/OAuthUtils.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,11 @@
1616
package io.polaris.service.auth;
1717

1818
import jakarta.ws.rs.core.Response;
19-
import java.nio.charset.StandardCharsets;
20-
import org.apache.commons.codec.binary.Base64;
2119

2220
/** Simple utility class to assist with OAuth operations */
2321
public class OAuthUtils {
24-
25-
public static final String AUTHORIZATION_HEADER = "Authorization";
26-
27-
public static final String SF_HEADER_ACCOUNT_NAME = "Snowflake-Account";
28-
2922
public static final String POLARIS_ROLE_PREFIX = "PRINCIPAL_ROLE:";
3023

31-
public static final String SF_ACCOUNT_NAME_HEADER = "sf-account";
32-
public static final String SF_ACCOUNT_URL_HEADER = "sf-account-url";
33-
34-
/**
35-
* @return basic Authorization Header of the form `base64_encode(client_id:client_secret)
36-
*/
37-
public static String getBasicAuthHeader(String clientId, String clientSecret) {
38-
return Base64.encodeBase64String(
39-
(clientId + ":" + clientSecret).getBytes(StandardCharsets.UTF_8));
40-
}
41-
4224
public static Response getResponseFromError(OAuthTokenErrorResponse.Error error) {
4325
return switch (error) {
4426
case unauthorized_client ->

polaris-service/src/main/java/io/polaris/service/catalog/BasePolarisCatalog.java

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public class BasePolarisCatalog extends BaseMetastoreViewCatalog
109109
private static final Logger LOG = LoggerFactory.getLogger(BasePolarisCatalog.class);
110110

111111
private static final Joiner SLASH = Joiner.on("/");
112-
private static final Joiner DOT = Joiner.on(".");
113112

114113
// Config key for whether to allow setting the FILE_IO_IMPL using catalog properties. Should
115114
// only be allowed in dev/test environments.
@@ -351,8 +350,7 @@ public boolean dropTable(TableIdentifier tableIdentifier, boolean purge) {
351350
})
352351
.orElse(Map.of());
353352
PolarisMetaStoreManager.DropEntityResult dropEntityResult =
354-
dropTableLike(
355-
catalogId, PolarisEntitySubType.TABLE, tableIdentifier, storageProperties, purge);
353+
dropTableLike(PolarisEntitySubType.TABLE, tableIdentifier, storageProperties, purge);
356354
if (!dropEntityResult.isSuccess()) {
357355
return false;
358356
}
@@ -376,7 +374,7 @@ public List<TableIdentifier> listTables(Namespace namespace) {
376374
"Cannot list tables for namespace. Namespace does not exist: %s", namespace);
377375
}
378376

379-
return listTableLike(catalogId, PolarisEntitySubType.TABLE, namespace);
377+
return listTableLike(PolarisEntitySubType.TABLE, namespace);
380378
}
381379

382380
@Override
@@ -385,7 +383,7 @@ public void renameTable(TableIdentifier from, TableIdentifier to) {
385383
return;
386384
}
387385

388-
renameTableLike(catalogId, PolarisEntitySubType.TABLE, from, to);
386+
renameTableLike(PolarisEntitySubType.TABLE, from, to);
389387
}
390388

391389
@Override
@@ -700,7 +698,7 @@ public List<TableIdentifier> listViews(Namespace namespace) {
700698
"Cannot list views for namespace. Namespace does not exist: %s", namespace);
701699
}
702700

703-
return listTableLike(catalogId, PolarisEntitySubType.VIEW, namespace);
701+
return listTableLike(PolarisEntitySubType.VIEW, namespace);
704702
}
705703

706704
@Override
@@ -710,8 +708,7 @@ protected BasePolarisViewOperations newViewOps(TableIdentifier identifier) {
710708

711709
@Override
712710
public boolean dropView(TableIdentifier identifier) {
713-
return dropTableLike(catalogId, PolarisEntitySubType.VIEW, identifier, Map.of(), true)
714-
.isSuccess();
711+
return dropTableLike(PolarisEntitySubType.VIEW, identifier, Map.of(), true).isSuccess();
715712
}
716713

717714
@Override
@@ -720,14 +717,14 @@ public void renameView(TableIdentifier from, TableIdentifier to) {
720717
return;
721718
}
722719

723-
renameTableLike(catalogId, PolarisEntitySubType.VIEW, from, to);
720+
renameTableLike(PolarisEntitySubType.VIEW, from, to);
724721
}
725722

726723
@Override
727724
public boolean sendNotification(
728725
TableIdentifier identifier, NotificationRequest notificationRequest) {
729726
return sendNotificationForTableLike(
730-
catalogId, PolarisEntitySubType.TABLE, identifier, notificationRequest);
727+
PolarisEntitySubType.TABLE, identifier, notificationRequest);
731728
}
732729

733730
@Override
@@ -1060,11 +1057,9 @@ private void validateNoLocationOverlap(
10601057

10611058
private class BasePolarisCatalogTableBuilder
10621059
extends BaseMetastoreViewCatalog.BaseMetastoreViewCatalogTableBuilder {
1063-
private final TableIdentifier identifier;
10641060

10651061
public BasePolarisCatalogTableBuilder(TableIdentifier identifier, Schema schema) {
10661062
super(identifier, schema);
1067-
this.identifier = identifier;
10681063
}
10691064

10701065
@Override
@@ -1074,11 +1069,9 @@ public TableBuilder withLocation(String newLocation) {
10741069
}
10751070

10761071
private class BasePolarisCatalogViewBuilder extends BaseMetastoreViewCatalog.BaseViewBuilder {
1077-
private final TableIdentifier identifier;
10781072

10791073
public BasePolarisCatalogViewBuilder(TableIdentifier identifier) {
10801074
super(identifier);
1081-
this.identifier = identifier;
10821075
}
10831076

10841077
@Override
@@ -1130,7 +1123,6 @@ public void doRefresh() {
11301123
MAX_RETRIES,
11311124
metadataLocation -> {
11321125
FileIO fileIO = this.tableFileIO;
1133-
boolean closeFileIO = false;
11341126
PolarisResolvedPathWrapper resolvedStorageEntity =
11351127
resolvedEntities == null
11361128
? resolvedEntityView.getResolvedPath(tableIdentifier.namespace())
@@ -1255,9 +1247,9 @@ public void doCommit(TableMetadata base, TableMetadata metadata) {
12551247
tableIdentifier, oldLocation, newLocation, existingLocation);
12561248
}
12571249
if (null == existingLocation) {
1258-
createTableLike(catalogId, tableIdentifier, entity);
1250+
createTableLike(tableIdentifier, entity);
12591251
} else {
1260-
updateTableLike(catalogId, tableIdentifier, entity);
1252+
updateTableLike(tableIdentifier, entity);
12611253
}
12621254
}
12631255

@@ -1477,9 +1469,9 @@ public void doCommit(ViewMetadata base, ViewMetadata metadata) {
14771469
identifier, oldLocation, newLocation, existingLocation);
14781470
}
14791471
if (null == existingLocation) {
1480-
createTableLike(catalogId, identifier, entity);
1472+
createTableLike(identifier, entity);
14811473
} else {
1482-
updateTableLike(catalogId, identifier, entity);
1474+
updateTableLike(identifier, entity);
14831475
}
14841476
}
14851477

@@ -1540,7 +1532,7 @@ long getCatalogId() {
15401532
}
15411533

15421534
private void renameTableLike(
1543-
long catalogId, PolarisEntitySubType subType, TableIdentifier from, TableIdentifier to) {
1535+
PolarisEntitySubType subType, TableIdentifier from, TableIdentifier to) {
15441536
LOG.debug("Renaming tableLike from {} to {}", from, to);
15451537
PolarisResolvedPathWrapper resolvedEntities = resolvedEntityView.getResolvedPath(from, subType);
15461538
if (resolvedEntities == null) {
@@ -1655,7 +1647,7 @@ private void renameTableLike(
16551647
* duplicate the logic to try to reolve parentIds before constructing the proposed entity. This
16561648
* method will fill in the parentId if needed upon resolution.
16571649
*/
1658-
private void createTableLike(long catalogId, TableIdentifier identifier, PolarisEntity entity) {
1650+
private void createTableLike(TableIdentifier identifier, PolarisEntity entity) {
16591651
PolarisResolvedPathWrapper resolvedParent =
16601652
resolvedEntityView.getResolvedPath(identifier.namespace());
16611653
if (resolvedParent == null) {
@@ -1664,14 +1656,11 @@ private void createTableLike(long catalogId, TableIdentifier identifier, Polaris
16641656
String.format("Failed to fetch resolved parent for TableIdentifier '%s'", identifier));
16651657
}
16661658

1667-
createTableLike(catalogId, identifier, entity, resolvedParent);
1659+
createTableLike(identifier, entity, resolvedParent);
16681660
}
16691661

16701662
private void createTableLike(
1671-
long catalogId,
1672-
TableIdentifier identifier,
1673-
PolarisEntity entity,
1674-
PolarisResolvedPathWrapper resolvedParent) {
1663+
TableIdentifier identifier, PolarisEntity entity, PolarisResolvedPathWrapper resolvedParent) {
16751664
// Make sure the metadata file is valid for our allowed locations.
16761665
String metadataLocation = TableLikeEntity.of(entity).getMetadataLocation();
16771666
validateLocationForTableLike(identifier, metadataLocation, resolvedParent);
@@ -1704,7 +1693,7 @@ private static boolean isUnderParentLocation(URI childLocation, URI expectedPare
17041693
return !expectedParentLocation.relativize(childLocation).equals(childLocation);
17051694
}
17061695

1707-
private void updateTableLike(long catalogId, TableIdentifier identifier, PolarisEntity entity) {
1696+
private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) {
17081697
PolarisResolvedPathWrapper resolvedEntities =
17091698
resolvedEntityView.getResolvedPath(identifier, entity.getSubType());
17101699
if (resolvedEntities == null) {
@@ -1733,7 +1722,6 @@ private void updateTableLike(long catalogId, TableIdentifier identifier, Polaris
17331722
}
17341723

17351724
private @NotNull PolarisMetaStoreManager.DropEntityResult dropTableLike(
1736-
long catalogId,
17371725
PolarisEntitySubType subType,
17381726
TableIdentifier identifier,
17391727
Map<String, String> storageProperties,
@@ -1759,10 +1747,7 @@ private void updateTableLike(long catalogId, TableIdentifier identifier, Polaris
17591747
}
17601748

17611749
private boolean sendNotificationForTableLike(
1762-
long catalogId,
1763-
PolarisEntitySubType subType,
1764-
TableIdentifier tableIdentifier,
1765-
NotificationRequest request) {
1750+
PolarisEntitySubType subType, TableIdentifier tableIdentifier, NotificationRequest request) {
17661751
LOG.debug("Handling notification request {} for tableIdentifier {}", request, tableIdentifier);
17671752
PolarisResolvedPathWrapper resolvedEntities =
17681753
resolvedEntityView.getPassthroughResolvedPath(tableIdentifier, subType);
@@ -1772,8 +1757,7 @@ private boolean sendNotificationForTableLike(
17721757
Preconditions.checkNotNull(notificationType, "Expected a valid notification type.");
17731758

17741759
if (notificationType == NotificationType.DROP) {
1775-
return dropTableLike(
1776-
catalogId, PolarisEntitySubType.TABLE, tableIdentifier, Map.of(), false /* purge */)
1760+
return dropTableLike(PolarisEntitySubType.TABLE, tableIdentifier, Map.of(), false /* purge */)
17771761
.isSuccess();
17781762
} else if (notificationType == NotificationType.CREATE
17791763
|| notificationType == NotificationType.UPDATE) {
@@ -1832,14 +1816,14 @@ private boolean sendNotificationForTableLike(
18321816
"Creating table {} for notification with metadataLocation {}",
18331817
tableIdentifier,
18341818
newLocation);
1835-
createTableLike(catalogId, tableIdentifier, entity, resolvedParent);
1819+
createTableLike(tableIdentifier, entity, resolvedParent);
18361820
} else {
18371821
LOG.debug(
18381822
"Updating table {} for notification with metadataLocation {}",
18391823
tableIdentifier,
18401824
newLocation);
18411825

1842-
updateTableLike(catalogId, tableIdentifier, entity);
1826+
updateTableLike(tableIdentifier, entity);
18431827
}
18441828
}
18451829
return true;
@@ -1863,8 +1847,7 @@ private void createNonExistingNamespaces(Namespace namespace) {
18631847
}
18641848
}
18651849

1866-
private List<TableIdentifier> listTableLike(
1867-
long catalogId, PolarisEntitySubType subType, Namespace namespace) {
1850+
private List<TableIdentifier> listTableLike(PolarisEntitySubType subType, Namespace namespace) {
18681851
PolarisResolvedPathWrapper resolvedEntities = resolvedEntityView.getResolvedPath(namespace);
18691852
if (resolvedEntities == null) {
18701853
// Illegal state because the namespace should've already been in the static resolution set.

polaris-service/src/main/java/io/polaris/service/catalog/IcebergCatalogAdapter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;
6161
import org.apache.iceberg.rest.requests.UpdateTableRequest;
6262
import org.apache.iceberg.rest.responses.ConfigResponse;
63-
import org.slf4j.Logger;
64-
import org.slf4j.LoggerFactory;
6563

6664
/**
6765
* {@link IcebergRestCatalogApiService} implementation that delegates operations to {@link
@@ -70,7 +68,6 @@
7068
*/
7169
public class IcebergCatalogAdapter
7270
implements IcebergRestCatalogApiService, IcebergRestConfigurationApiService {
73-
private static final Logger LOG = LoggerFactory.getLogger(IcebergCatalogAdapter.class);
7471

7572
private final CallContextCatalogFactory catalogFactory;
7673
private final RealmEntityManagerFactory entityManagerFactory;

polaris-service/src/main/java/io/polaris/service/task/ManifestFileCleanupTaskHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ private CompletableFuture<Void> tryDelete(
151151
// file's existence, but then it is deleted before we have a chance to
152152
// send the delete request. In such a case, we <i>should</i> retry
153153
// and find
154-
if (TaskUtils.exists(dataFile.toString(), fileIO)) {
155-
fileIO.deleteFile(dataFile.toString());
154+
if (TaskUtils.exists(dataFile, fileIO)) {
155+
fileIO.deleteFile(dataFile);
156156
} else {
157157
LOGGER
158158
.atInfo()

polaris-service/src/main/java/io/polaris/service/task/TableCleanupTaskHandler.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import io.polaris.core.persistence.PolarisMetaStoreManager;
2828
import java.util.List;
2929
import java.util.UUID;
30-
import java.util.concurrent.ExecutorService;
31-
import java.util.concurrent.Executors;
3230
import java.util.function.Function;
3331
import java.util.stream.Collectors;
3432
import org.apache.iceberg.ManifestFile;
@@ -48,7 +46,6 @@ public class TableCleanupTaskHandler implements TaskHandler {
4846
private final TaskExecutor taskExecutor;
4947
private final MetaStoreManagerFactory metaStoreManagerFactory;
5048
private final Function<TaskEntity, FileIO> fileIOSupplier;
51-
private final ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();
5249

5350
public TableCleanupTaskHandler(
5451
TaskExecutor taskExecutor,

polaris-service/src/test/java/io/polaris/service/catalog/BasePolarisCatalogTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,11 @@ public void testUpdateNotificationCreateTableWithHttpPrefix() {
642642
supportsNotifications(), "Only applicable if notifications are supported");
643643

644644
String catalogName = "catalogForMaliciousDomain";
645-
PolarisEntity catalogEntity =
646-
adminService.createCatalog(
647-
new CatalogEntity.Builder()
648-
.setDefaultBaseLocation("http://maliciousdomain.com")
649-
.setName(catalogName)
650-
.build());
645+
adminService.createCatalog(
646+
new CatalogEntity.Builder()
647+
.setDefaultBaseLocation("http://maliciousdomain.com")
648+
.setName(catalogName)
649+
.build());
651650

652651
CallContext callContext = CallContext.getCurrentContext();
653652
PolarisPassthroughResolutionView passthroughView =
@@ -1119,8 +1118,7 @@ private TableMetadata createSampleTableMetadata(String tableLocation) {
11191118
PartitionSpec partitionSpec =
11201119
PartitionSpec.builderFor(schema).identity("intType").withSpecId(1000).build();
11211120

1122-
return TableMetadata.newTableMetadata(
1123-
schema, partitionSpec, tableLocation, ImmutableMap.<String, String>of());
1121+
return TableMetadata.newTableMetadata(schema, partitionSpec, tableLocation, ImmutableMap.of());
11241122
}
11251123

11261124
private void createNonExistingNamespaces(Namespace namespace) {

polaris-service/src/test/java/io/polaris/service/catalog/BasePolarisCatalogViewTest.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,17 @@ public void before() {
108108
entityManager,
109109
authenticatedRoot,
110110
new PolarisAuthorizer(new PolarisConfigurationStore() {}));
111-
PolarisEntity catalogEntity =
112-
adminService.createCatalog(
113-
new CatalogEntity.Builder()
114-
.setName(CATALOG_NAME)
115-
.addProperty(PolarisConfiguration.CATALOG_ALLOW_EXTERNAL_TABLE_LOCATION, "true")
116-
.addProperty(PolarisConfiguration.CATALOG_ALLOW_UNSTRUCTURED_TABLE_LOCATION, "true")
117-
.setDefaultBaseLocation("file://tmp")
118-
.setStorageConfigurationInfo(
119-
new FileStorageConfigInfo(
120-
StorageConfigInfo.StorageTypeEnum.FILE, List.of("file://", "/", "*")),
121-
"file://tmp")
122-
.build());
111+
adminService.createCatalog(
112+
new CatalogEntity.Builder()
113+
.setName(CATALOG_NAME)
114+
.addProperty(PolarisConfiguration.CATALOG_ALLOW_EXTERNAL_TABLE_LOCATION, "true")
115+
.addProperty(PolarisConfiguration.CATALOG_ALLOW_UNSTRUCTURED_TABLE_LOCATION, "true")
116+
.setDefaultBaseLocation("file://tmp")
117+
.setStorageConfigurationInfo(
118+
new FileStorageConfigInfo(
119+
StorageConfigInfo.StorageTypeEnum.FILE, List.of("file://", "/", "*")),
120+
"file://tmp")
121+
.build());
123122

124123
PolarisPassthroughResolutionView passthroughView =
125124
new PolarisPassthroughResolutionView(

0 commit comments

Comments
 (0)