forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#3891] feat(catalog-lakehouse-paimon): Support schema operatio…
…ns for Paimon Catalog
- Loading branch information
caican
committed
Jun 21, 2024
1 parent
5a452f5
commit ec196c2
Showing
19 changed files
with
1,114 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...src/main/java/com/datastrato/gravitino/catalog/lakehouse/paimon/PaimonCatalogBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog.lakehouse.paimon; | ||
|
||
/** The type of Paimon catalog backend. */ | ||
public enum PaimonCatalogBackend { | ||
FILESYSTEM | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...va/com/datastrato/gravitino/catalog/lakehouse/paimon/PaimonCatalogPropertiesMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog.lakehouse.paimon; | ||
|
||
import static com.datastrato.gravitino.connector.PropertyEntry.enumImmutablePropertyEntry; | ||
import static com.datastrato.gravitino.connector.PropertyEntry.stringOptionalPropertyEntry; | ||
import static com.datastrato.gravitino.connector.PropertyEntry.stringRequiredPropertyEntry; | ||
|
||
import com.datastrato.gravitino.connector.BaseCatalogPropertiesMetadata; | ||
import com.datastrato.gravitino.connector.PropertiesMetadata; | ||
import com.datastrato.gravitino.connector.PropertyEntry; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.Maps; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Implementation of {@link PropertiesMetadata} that represents Paimon catalog properties metadata. | ||
*/ | ||
public class PaimonCatalogPropertiesMetadata extends BaseCatalogPropertiesMetadata { | ||
|
||
public static final String GRAVITINO_CATALOG_BACKEND = "catalog-backend"; | ||
public static final String PAIMON_METASTORE = "metastore"; | ||
public static final String WAREHOUSE = "warehouse"; | ||
public static final String URI = "uri"; | ||
|
||
private static final Map<String, PropertyEntry<?>> PROPERTIES_METADATA; | ||
|
||
public static final Map<String, String> GRAVITINO_CONFIG_TO_PAIMON = | ||
ImmutableMap.of(GRAVITINO_CATALOG_BACKEND, PAIMON_METASTORE, WAREHOUSE, WAREHOUSE, URI, URI); | ||
|
||
static { | ||
List<PropertyEntry<?>> propertyEntries = | ||
ImmutableList.of( | ||
enumImmutablePropertyEntry( | ||
GRAVITINO_CATALOG_BACKEND, | ||
"Paimon catalog backend type", | ||
true, | ||
PaimonCatalogBackend.class, | ||
null, | ||
false, | ||
false), | ||
stringRequiredPropertyEntry(WAREHOUSE, "Paimon catalog warehouse config", false, false), | ||
stringOptionalPropertyEntry(URI, "Paimon catalog uri config", false, null, false)); | ||
HashMap<String, PropertyEntry<?>> result = Maps.newHashMap(BASIC_CATALOG_PROPERTY_ENTRIES); | ||
result.putAll(Maps.uniqueIndex(propertyEntries, PropertyEntry::getName)); | ||
PROPERTIES_METADATA = ImmutableMap.copyOf(result); | ||
} | ||
|
||
@Override | ||
protected Map<String, PropertyEntry<?>> specificPropertyEntries() { | ||
return PROPERTIES_METADATA; | ||
} | ||
|
||
public Map<String, String> transformProperties(Map<String, String> properties) { | ||
Map<String, String> gravitinoConfig = Maps.newHashMap(); | ||
properties.forEach( | ||
(key, value) -> { | ||
if (GRAVITINO_CONFIG_TO_PAIMON.containsKey(key)) { | ||
gravitinoConfig.put(GRAVITINO_CONFIG_TO_PAIMON.get(key), value); | ||
} | ||
}); | ||
return gravitinoConfig; | ||
} | ||
} |
Oops, something went wrong.