dataroaring commented on code in PR #45325:
URL: https://github.com/apache/doris/pull/45325#discussion_r1996531756
##########
fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java:
##########
@@ -1193,28 +1195,49 @@ public static String analyzeStoragePolicy(Map<String,
String> properties) {
return storagePolicy;
}
- /**
- * @param properties
- * @return <storageVaultName, storageVaultId>
- * @throws AnalysisException
- */
- public static Pair<String, String> analyzeStorageVault(Map<String, String>
properties) throws AnalysisException {
+ public static String analyzeStorageVaultName(Map<String, String>
properties) {
String storageVaultName = null;
if (properties != null &&
properties.containsKey(PROPERTIES_STORAGE_VAULT_NAME)) {
storageVaultName = properties.get(PROPERTIES_STORAGE_VAULT_NAME);
properties.remove(PROPERTIES_STORAGE_VAULT_NAME);
}
+ return storageVaultName;
+ }
+
+ /**
+ * @param properties, db
+ * @return <storageVaultName, storageVaultId>
+ * @throws AnalysisException
+ */
+ public static Pair<String, String> analyzeStorageVault(Map<String, String>
properties, Database db)
+ throws AnalysisException {
+ String storageVaultName = analyzeStorageVaultName(properties);
+ String storageVaultId = null;
+
if (Strings.isNullOrEmpty(storageVaultName)) {
- // If user does not specify one storage vault then FE would use
the default vault
- Pair<String, String> info =
Env.getCurrentEnv().getStorageVaultMgr().getDefaultStorageVault();
- if (info == null) {
- throw new AnalysisException("No default storage vault."
- + " You can use `SHOW STORAGE VAULT` to get all
available vaults,"
- + " and pick one set default vault with `SET
<vault_name> AS DEFAULT STORAGE VAULT`");
+ // If user does not specify one storage vault then FE would check
db's storage vault then the default vault
+ // the storage vault inherit order is as follows: table -> db ->
default
+ if (db.getDbProperties() != null) {
+ Map<String, String> dbProperties = new
HashMap<>(db.getDbProperties().getProperties());
+ storageVaultName =
PropertyAnalyzer.analyzeStorageVaultName(dbProperties);
+ }
+
+ if (!Strings.isNullOrEmpty(storageVaultName)) {
+ storageVaultId =
Env.getCurrentEnv().getStorageVaultMgr().getVaultIdByName(storageVaultName);
Review Comment:
duplicated code as below.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]