mchades commented on code in PR #4942:
URL: https://github.com/apache/gravitino/pull/4942#discussion_r1796387229
##########
catalogs/catalog-lakehouse-hudi/src/main/java/org/apache/gravitino/catalog/lakehouse/hudi/backend/hms/HudiHMSBackendOps.java:
##########
@@ -73,12 +126,57 @@ public boolean dropSchema(NameIdentifier ident, boolean
cascade) throws NonEmpty
@Override
public NameIdentifier[] listTables(Namespace namespace) throws
NoSuchSchemaException {
- throw new UnsupportedOperationException("Not implemented yet");
+ NameIdentifier schemaIdent = NameIdentifier.of(namespace.levels());
+ if (!schemaExists(schemaIdent)) {
+ throw new NoSuchSchemaException("Schema (database) does not exist %s",
namespace);
+ }
+
+ try {
+ return clientPool.run(
+ c -> {
+ List<String> allTables = c.getAllTables(schemaIdent.name());
+ return c.getTableObjectsByName(schemaIdent.name(),
allTables).stream()
+ .filter(
+ t ->
+ t.getSd().getInputFormat() != null
+ &&
t.getSd().getInputFormat().startsWith("org.apache.hudi"))
+ .map(t -> NameIdentifier.of(namespace, t.getTableName()))
+ .toArray(NameIdentifier[]::new);
+ });
+
+ } catch (UnknownDBException e) {
+ throw new NoSuchSchemaException(
+ "Schema (database) does not exist %s in Hive Metastore", namespace);
+
+ } catch (TException e) {
+ throw new RuntimeException(
+ "Failed to list all tables under the namespace : " + namespace + "
in Hive Metastore", e);
+
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
- public HudiHMSTable loadTable(NameIdentifier ident) throws
NoSuchTableException {
- throw new UnsupportedOperationException("Not implemented yet");
+ public HudiTable loadTable(NameIdentifier tableIdent) throws
NoSuchTableException {
+ NameIdentifier schemaIdent =
NameIdentifier.of(tableIdent.namespace().levels());
+
+ try {
+ Table table =
+ clientPool.run(client -> client.getTable(schemaIdent.name(),
tableIdent.name()));
+ return HudiHMSTable.builder().withBackendTable(table).build();
Review Comment:
fixed
##########
catalogs/catalog-lakehouse-hudi/src/main/java/org/apache/gravitino/catalog/lakehouse/hudi/backend/hms/HudiHMSBackendOps.java:
##########
@@ -73,12 +126,57 @@ public boolean dropSchema(NameIdentifier ident, boolean
cascade) throws NonEmpty
@Override
public NameIdentifier[] listTables(Namespace namespace) throws
NoSuchSchemaException {
- throw new UnsupportedOperationException("Not implemented yet");
+ NameIdentifier schemaIdent = NameIdentifier.of(namespace.levels());
+ if (!schemaExists(schemaIdent)) {
+ throw new NoSuchSchemaException("Schema (database) does not exist %s",
namespace);
+ }
+
+ try {
+ return clientPool.run(
+ c -> {
+ List<String> allTables = c.getAllTables(schemaIdent.name());
+ return c.getTableObjectsByName(schemaIdent.name(),
allTables).stream()
+ .filter(
+ t ->
+ t.getSd().getInputFormat() != null
+ &&
t.getSd().getInputFormat().startsWith("org.apache.hudi"))
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]