Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kroushan-nit committed Dec 19, 2024
1 parent 8c5c49b commit e50889b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,4 @@ public TargetTable(
this.metadataRetention =
metadataRetention == null ? Duration.of(7, ChronoUnit.DAYS) : metadataRetention;
}

public String getId() {
return String.format("%s#%s", sanitizeBasePath(this.basePath), formatName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public class CatalogTableIdentifier {
* from the table name in storage.
*/
@NonNull String tableName;

@Override
public String toString() {
return String.format("%s.%s", databaseName, tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public HMSCatalogSyncClient(
tableFormat, this.configuration, this.schemaExtractor);
}

public HMSCatalogSyncClient(ExternalCatalogConfig catalogConfig, Configuration configuration) {
this.catalogConfig = catalogConfig;
this.hmsCatalogConfig = HMSCatalogConfig.of(catalogConfig.getCatalogOptions());
this.configuration = configuration;
this.schemaExtractor = HMSSchemaExtractor.getInstance();
try {
this.metaStoreClient = new HMSClient(hmsCatalogConfig, configuration).getMSC();
} catch (MetaException | HiveException e) {
throw new CatalogSyncException("HiveMetastoreClient could not be created", e);
}
// TODO: should we keep this null or add some default initialization
this.hmsCatalogSyncRequestProvider = null;
}

@VisibleForTesting
HMSCatalogSyncClient(
ExternalCatalogConfig catalogConfig,
Expand All @@ -97,12 +111,7 @@ public String getCatalogName() {
}

@Override
public String getCatalogImpl() {
return this.getClass().getCanonicalName();
}

@Override
public String getStorageDescriptorLocation(Table table) {
public String getStorageLocation(Table table) {
if (table == null || table.getSd() == null) {
return null;
}
Expand Down Expand Up @@ -143,7 +152,7 @@ public Table getTable(CatalogTableIdentifier tableIdentifier) {
} catch (NoSuchObjectException e) {
return null;
} catch (TException e) {
throw new CatalogSyncException("Failed to get table: " + tableIdentifier.getId(), e);
throw new CatalogSyncException("Failed to get table: " + tableIdentifier, e);
}
}

Expand All @@ -153,7 +162,7 @@ public void createTable(InternalTable table, CatalogTableIdentifier tableIdentif
try {
metaStoreClient.createTable(hmsTable);
} catch (TException e) {
throw new CatalogSyncException("Failed to create table: " + tableIdentifier.getId(), e);
throw new CatalogSyncException("Failed to create table: " + tableIdentifier, e);
}
}

Expand All @@ -165,7 +174,7 @@ public void refreshTable(
metaStoreClient.alter_table(
tableIdentifier.getDatabaseName(), tableIdentifier.getTableName(), catalogTable);
} catch (TException e) {
throw new CatalogSyncException("Failed to refresh table: " + tableIdentifier.getId(), e);
throw new CatalogSyncException("Failed to refresh table: " + tableIdentifier, e);
}
}

Expand All @@ -182,7 +191,7 @@ public void dropTable(InternalTable table, CatalogTableIdentifier tableIdentifie
try {
metaStoreClient.dropTable(tableIdentifier.getDatabaseName(), tableIdentifier.getTableName());
} catch (TException e) {
throw new CatalogSyncException("Failed to drop table: " + tableIdentifier.getId(), e);
throw new CatalogSyncException("Failed to drop table: " + tableIdentifier, e);
}
}

Expand Down Expand Up @@ -216,7 +225,7 @@ public SourceTable getSourceTable(CatalogTableIdentifier tableIdentifier) {
Table table = this.getTable(tableIdentifier);
if (table == null) {
throw new IllegalStateException(
String.format("table: %s not found", tableIdentifier.getId()));
String.format("table: %s not found", tableIdentifier));
}

String tableFormat = table.getParameters().get(TABLE_TYPE_PROP).toUpperCase(Locale.ENGLISH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Table getCreateTableInput(InternalTable table, CatalogTableIdentifier tableIdent
return newTb;
} catch (IOException e) {
throw new RuntimeException(
"Failed to set owner for hms table: " + tableIdentifier.getId(), e);
"Failed to set owner for hms table: " + tableIdentifier, e);
}
}

Expand Down

0 comments on commit e50889b

Please sign in to comment.