[HUDI-2837] Add support for using database name in incremental query (#4083)
This commit is contained in:
@@ -76,6 +76,12 @@ public class HoodieTableConfig extends HoodieConfig {
|
||||
public static final String HOODIE_PROPERTIES_FILE = "hoodie.properties";
|
||||
public static final String HOODIE_PROPERTIES_FILE_BACKUP = "hoodie.properties.backup";
|
||||
|
||||
public static final ConfigProperty<String> DATABASE_NAME = ConfigProperty
|
||||
.key("hoodie.database.name")
|
||||
.noDefaultValue()
|
||||
.withDocumentation("Database name that will be used for incremental query.If different databases have the same table name during incremental query, "
|
||||
+ "we can set it to limit the table name under a specific database");
|
||||
|
||||
public static final ConfigProperty<String> NAME = ConfigProperty
|
||||
.key("hoodie.table.name")
|
||||
.noDefaultValue()
|
||||
@@ -422,6 +428,13 @@ public class HoodieTableConfig extends HoodieConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the database name.
|
||||
*/
|
||||
public String getDatabaseName() {
|
||||
return getString(DATABASE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the table name.
|
||||
*/
|
||||
|
||||
@@ -624,6 +624,7 @@ public class HoodieTableMetaClient implements Serializable {
|
||||
public static class PropertyBuilder {
|
||||
|
||||
private HoodieTableType tableType;
|
||||
private String databaseName;
|
||||
private String tableName;
|
||||
private String tableCreateSchema;
|
||||
private String recordKeyFields;
|
||||
@@ -655,6 +656,11 @@ public class HoodieTableMetaClient implements Serializable {
|
||||
return setTableType(HoodieTableType.valueOf(tableType));
|
||||
}
|
||||
|
||||
public PropertyBuilder setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PropertyBuilder setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
return this;
|
||||
@@ -753,6 +759,9 @@ public class HoodieTableMetaClient implements Serializable {
|
||||
|
||||
public PropertyBuilder fromProperties(Properties properties) {
|
||||
HoodieConfig hoodieConfig = new HoodieConfig(properties);
|
||||
if (hoodieConfig.contains(HoodieTableConfig.DATABASE_NAME)) {
|
||||
setDatabaseName(hoodieConfig.getString(HoodieTableConfig.DATABASE_NAME));
|
||||
}
|
||||
if (hoodieConfig.contains(HoodieTableConfig.NAME)) {
|
||||
setTableName(hoodieConfig.getString(HoodieTableConfig.NAME));
|
||||
}
|
||||
@@ -819,6 +828,9 @@ public class HoodieTableMetaClient implements Serializable {
|
||||
ValidationUtils.checkArgument(tableName != null, "tableName is null");
|
||||
|
||||
HoodieTableConfig tableConfig = new HoodieTableConfig();
|
||||
if (databaseName != null) {
|
||||
tableConfig.setValue(HoodieTableConfig.DATABASE_NAME, databaseName);
|
||||
}
|
||||
tableConfig.setValue(HoodieTableConfig.NAME, tableName);
|
||||
tableConfig.setValue(HoodieTableConfig.TYPE, tableType.name());
|
||||
tableConfig.setValue(HoodieTableConfig.VERSION,
|
||||
|
||||
Reference in New Issue
Block a user