Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions catalogs/catalog-generic-lakehouse/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation(libs.commons.lang3)
implementation(libs.guava)
implementation(libs.hadoop3.client.api)
implementation(libs.hadoop3.client.runtime)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need to add this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the method dropTable, the following code will lack necessary dependencies if there exists only hadoop-client-api

      FileSystem fs = FileSystem.get(new Configuration());
      return fs.delete(new Path(location), true);

They should show up together.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will optimize this part in another PR and remove the use of FileSystem here.

implementation(libs.lance)

annotationProcessor(libs.lombok)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@
import org.apache.gravitino.rel.expressions.transforms.Transform;
import org.apache.gravitino.rel.indexes.Index;
import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Operations for interacting with a generic lakehouse catalog in Apache Gravitino. */
public class GenericLakehouseCatalogOperations
implements CatalogOperations, SupportsSchemas, TableCatalog {
private static final Logger LOG =
LoggerFactory.getLogger(GenericLakehouseCatalogOperations.class);

private static final String SLASH = "/";

Expand Down Expand Up @@ -282,24 +286,27 @@ public Table alterTable(NameIdentifier ident, TableChange... changes)
@Override
public boolean dropTable(NameIdentifier ident) {
EntityStore store = GravitinoEnv.getInstance().entityStore();
Namespace namespace = ident.namespace();
GenericTableEntity tableEntity;
try {
GenericTableEntity tableEntity =
store.get(ident, Entity.EntityType.TABLE, GenericTableEntity.class);
Map<String, String> tableProperties = tableEntity.getProperties();
String format = tableProperties.getOrDefault("format", "lance");
LakehouseCatalogOperations lakehouseCatalogOperations =
SUPPORTED_FORMATS.compute(
format,
(k, v) ->
v == null
? createLakehouseCatalogOperations(
format, tableProperties, catalogInfo, propertiesMetadata)
: v);
return lakehouseCatalogOperations.dropTable(ident);
} catch (IOException e) {
throw new RuntimeException("Failed to list tables under schema " + namespace, e);
tableEntity = store.get(ident, Entity.EntityType.TABLE, GenericTableEntity.class);
} catch (NoSuchEntityException e) {
LOG.warn("Table {} does not exist, skip dropping.", ident);
return false;
} catch (IOException ioe) {
throw new RuntimeException("Failed to get table " + ident);
}

Map<String, String> tableProperties = tableEntity.getProperties();
String format = tableProperties.getOrDefault("format", "lance");
LakehouseCatalogOperations lakehouseCatalogOperations =
SUPPORTED_FORMATS.compute(
format,
(k, v) ->
v == null
? createLakehouseCatalogOperations(
format, tableProperties, catalogInfo, propertiesMetadata)
: v);
return lakehouseCatalogOperations.dropTable(ident);
}

private String ensureTrailingSlash(String path) {
Expand Down
Loading