codope commented on code in PR #18054:
URL: https://github.com/apache/hudi/pull/18054#discussion_r2749687236
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -949,8 +949,16 @@ private HoodieTableMetaClient initializeMetaClient()
throws IOException {
.setBaseFileFormat(HoodieFileFormat.HFILE.toString())
.setRecordKeyFields(RECORD_KEY_FIELD_NAME)
.setPopulateMetaFields(DEFAULT_METADATA_POPULATE_META_FIELDS)
-
.setKeyGeneratorClassProp(HoodieTableMetadataKeyGenerator.class.getCanonicalName())
- .initTable(storageConf.newInstance(),
metadataWriteConfig.getBasePath());
+
.setKeyGeneratorClassProp(HoodieTableMetadataKeyGenerator.class.getCanonicalName());
+
+ // Get the database name from dataTable config
Review Comment:
```suggestion
// Propagate the database name from the data table to the metadata
table, if present
```
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -949,8 +949,16 @@ private HoodieTableMetaClient initializeMetaClient()
throws IOException {
.setBaseFileFormat(HoodieFileFormat.HFILE.toString())
.setRecordKeyFields(RECORD_KEY_FIELD_NAME)
.setPopulateMetaFields(DEFAULT_METADATA_POPULATE_META_FIELDS)
-
.setKeyGeneratorClassProp(HoodieTableMetadataKeyGenerator.class.getCanonicalName())
- .initTable(storageConf.newInstance(),
metadataWriteConfig.getBasePath());
+
.setKeyGeneratorClassProp(HoodieTableMetadataKeyGenerator.class.getCanonicalName());
+
+ // Get the database name from dataTable config
+ String databaseName = dataMetaClient.getTableConfig().getDatabaseName();
+
+ if (!StringUtils.isNullOrEmpty(databaseName)) {
+ builder.setDatabaseName(databaseName);
+ }
Review Comment:
What happens if an existing metadata table was created without the db name,
and later the data table is updated with a db name? Will the metadata table db
name be updated? It is probably fine in most use cases if it won't be updated,
but worth documenting.
--
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]