Skip to content

Commit

Permalink
[apache#5560] Add support for extra catalogs in the Gravitino CLI (ap…
Browse files Browse the repository at this point in the history
…ache#5752)

### What changes were proposed in this pull request?

Expand Gravitino CLI support.

### Why are the changes needed?

Add support for all current catalogs.

Fix: apache#5560

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Tested locally.
  • Loading branch information
justinmclean authored Dec 4, 2024
1 parent 4d8f9fa commit 0327979
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
20 changes: 20 additions & 0 deletions clients/cli/src/main/java/org/apache/gravitino/cli/Providers.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class Providers {
public static final String MYSQL = "mysql";
public static final String POSTGRES = "postgres";
public static final String KAFKA = "kafka";
public static final String DORIS = "doris";
public static final String PAIMON = "paimon";
public static final String HUDI = "hudi";
public static final String OCEANBASE = "oceanbase";

private static final HashSet<String> VALID_PROVIDERS = new HashSet<>();

Expand All @@ -43,6 +47,10 @@ public class Providers {
VALID_PROVIDERS.add(MYSQL);
VALID_PROVIDERS.add(POSTGRES);
VALID_PROVIDERS.add(KAFKA);
VALID_PROVIDERS.add(DORIS);
VALID_PROVIDERS.add(PAIMON);
VALID_PROVIDERS.add(HUDI);
VALID_PROVIDERS.add(OCEANBASE);
}

/**
Expand All @@ -69,6 +77,14 @@ public static String internal(String provider) {
return "lakehouse-iceberg";
case KAFKA:
return "kafka";
case DORIS:
return "jdbc-doris";
case PAIMON:
return "lakehouse-paimon";
case HUDI:
return "lakehouse-hudi";
case OCEANBASE:
return "jdbc-oceanbase";
default:
throw new IllegalArgumentException("Unsupported provider: " + provider);
}
Expand All @@ -82,6 +98,10 @@ public static Catalog.Type catalogType(String provider) {
case MYSQL:
case POSTGRES:
case ICEBERG:
case DORIS:
case PAIMON:
case HUDI:
case OCEANBASE:
return Catalog.Type.RELATIONAL;
case KAFKA:
return Catalog.Type.MESSAGING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public void validProviders() {
assertTrue(Providers.isValidProvider(Providers.MYSQL), "MYSQL should be a valid entity");
assertTrue(Providers.isValidProvider(Providers.POSTGRES), "POSTGRES should be a valid entity");
assertTrue(Providers.isValidProvider(Providers.KAFKA), "KAFKA should be a valid entity");
assertTrue(Providers.isValidProvider(Providers.DORIS), "DORIS should be a valid entity");
assertTrue(Providers.isValidProvider(Providers.PAIMON), "PAIMON should be a valid entity");
assertTrue(Providers.isValidProvider(Providers.HUDI), "HUDI should be a valid entity");
assertTrue(
Providers.isValidProvider(Providers.OCEANBASE), "OCEANBASE should be a valid entity");
}

@Test
Expand Down Expand Up @@ -70,6 +75,10 @@ public void internalNotNull() {
assertNotNull(Providers.internal(Providers.MYSQL), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.POSTGRES), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.KAFKA), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.DORIS), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.PAIMON), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.HUDI), "Internal string should not be null");
assertNotNull(Providers.internal(Providers.OCEANBASE), "Internal string should not be null");
}

@Test
Expand All @@ -88,6 +97,10 @@ public void catalogTypeNotNull() {
assertNotNull(Providers.catalogType(Providers.MYSQL), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.POSTGRES), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.KAFKA), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.DORIS), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.PAIMON), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.HUDI), "Catalog type should not be null");
assertNotNull(Providers.catalogType(Providers.OCEANBASE), "Catalog type should not be null");
}

@Test
Expand Down
24 changes: 24 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ gcli catalog create -name postgres --provider postgres --properties jdbc-url=jd
gcli catalog create --name kafka --provider kafka --properties bootstrap.servers=127.0.0.1:9092,127.0.0.2:9092
```

##### Create a Doris catalog

```bash
gcli catalog create --name doris --provider doris --properties jdbc-url=jdbc:mysql://localhost:9030,jdbc-driver=com.mysql.jdbc.Driver,jdbc-user=admin,jdbc-password=password
```

##### Create a Paimon catalog

```bash
gcli catalog create --name paimon --provider paimon --properties catalog-backend=jdbc,uri=jdbc:mysql://127.0.0.1:3306/metastore_db,authentication.type=simple
```

#### Create a Hudi catalog

```bash
gcli catalog create --name hudi --provider hudi --properties catalog-backend=hms,uri=thrift://127.0.0.1:9083
```

#### Create an Oceanbase catalog

```bash
gcli catalog create --name oceanbase --provider oceanbase --properties jdbc-url=jdbc:mysql://localhost:2881,jdbc-driver=com.mysql.jdbc.Driver,jdbc-user=admin,jdbc-password=password
```

#### Delete a catalog

```bash
Expand Down

0 comments on commit 0327979

Please sign in to comment.