Skip to content

Commit

Permalink
[hive] Add a option for HiveCatalog to decide sync all properties to hms
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyu committed Aug 15, 2024
1 parent 65df3f9 commit 8a120bf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/layouts/shortcodes/generated/catalog_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
<td>String</td>
<td>Metastore of paimon catalog, supports filesystem, hive and jdbc.</td>
</tr>
<tr>
<td><h5>sync-all-properties</h5></td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>Sync all table properties to hive metastore</td>
</tr>
<tr>
<td><h5>table.type</h5></td>
<td style="word-wrap: break-word;">managed</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,10 @@ public class CatalogOptions {
.withDescription(
"Indicates whether this catalog allow upper case, "
+ "its default value depends on the implementation of the specific catalog.");

public static final ConfigOption<Boolean> SYNC_ALL_PROPERTIES =
ConfigOptions.key("sync-all-properties")
.booleanType()
.defaultValue(false)
.withDescription("Sync all table properties to hive metastore");
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import static org.apache.paimon.hive.HiveCatalogOptions.IDENTIFIER;
import static org.apache.paimon.hive.HiveCatalogOptions.LOCATION_IN_PROPERTIES;
import static org.apache.paimon.options.CatalogOptions.ALLOW_UPPER_CASE;
import static org.apache.paimon.options.CatalogOptions.SYNC_ALL_PROPERTIES;
import static org.apache.paimon.options.CatalogOptions.TABLE_TYPE;
import static org.apache.paimon.options.OptionsUtils.convertToPropertiesPrefixKey;
import static org.apache.paimon.utils.BranchManager.DEFAULT_MAIN_BRANCH;
Expand Down Expand Up @@ -516,10 +517,14 @@ protected void createTableImpl(Identifier identifier, Schema schema) {
}

private Table createHiveTable(Identifier identifier, TableSchema tableSchema) {
Table table =
newHmsTable(
identifier,
convertToPropertiesPrefixKey(tableSchema.options(), HIVE_PREFIX));
Map<String, String> tblProperties;
if (syncAllProperties()) {
tblProperties = new HashMap<>(tableSchema.options());
} else {
tblProperties = convertToPropertiesPrefixKey(tableSchema.options(), HIVE_PREFIX);
}

Table table = newHmsTable(identifier, tblProperties);
updateHmsTable(table, identifier, tableSchema);
return table;
}
Expand Down Expand Up @@ -607,6 +612,10 @@ public boolean allowUpperCase() {
return catalogOptions.getOptional(ALLOW_UPPER_CASE).orElse(false);
}

public boolean syncAllProperties() {
return catalogOptions.get(SYNC_ALL_PROPERTIES);
}

@Override
public void repairCatalog() {
List<String> databases = null;
Expand Down

0 comments on commit 8a120bf

Please sign in to comment.