-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UT] optimize error message when creating hive/iceberg db/table #45612
[UT] optimize error message when creating hive/iceberg db/table #45612
Conversation
throw new StarRocksConnectorException("Failed checking path: " + path); | ||
} | ||
} | ||
|
||
public static void createDirectory(Path path, Configuration conf) { | ||
try { | ||
FileSystem fileSystem = FileSystem.get(path.toUri(), conf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
the removal of the check for LOCATION_PROPERTY
in the checkLocationProperties
method.
You can modify the code like this:
public static void checkLocationProperties(Map<String, String> properties) throws DdlException {
// Add back the check for both EXTERNAL_LOCATION_PROPERTY and LOCATION_PROPERTY
if (properties.containsKey(EXTERNAL_LOCATION_PROPERTY) || properties.containsKey(LOCATION_PROPERTY)) {
throw new DdlException("Can't create non-managed Hive table. " +
"Only supports creating hive table under Database location. " +
"You could execute command without location properties");
}
}
This modification considers scenarios where either EXTERNAL_LOCATION_PROPERTY
or the previously checked LOCATION_PROPERTY
are included in the properties map, ensuring that the code handles both situations appropriately and prevents the creation of non-managed Hive tables with inappropriate location properties.
throw new StarRocksConnectorException("Failed to find location in database '%s'. Please define the location" + | ||
" when you create table or recreate another database with location." + | ||
" You could execute the SQL command like 'CREATE TABLE <table_name> <columns> " + | ||
"PROPERTIES('location' = '<location>')", dbName); | ||
} | ||
|
||
String dbLocation = database.getLocation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
Database location validation is removed for GLUE metastore.
You can modify the code like this:
@@ -104,12 +103,6 @@ public void createDb(String dbName, Map<String, String> properties) {
}
}
+ if ((dbLocation == null || dbLocation.isEmpty()) && metastoreType == MetastoreType.GLUE) {
+ throw new StarRocksConnectorException("The database location must be set when using glue. " +
+ "you could execute command like " +
+ "'CREATE DATABASE <db_name> properties('location'='s3://<bucket>/<your_db_path>')'");
+ }
+
metastore.createDb(dbName, properties);
}
Reintroducing the check for a database location ensures that when using the GLUE metastore, the database location must be explicitly defined. This is important because the absence of this validation might lead to an inconsistency in the way databases are created between different metastores and potentially cause runtime failures or misconfigurations when relying on GLUE’s behavior.
"PROPERTIES('location' = '<location>')", dbName); | ||
} | ||
} | ||
|
||
Table nativeTable = delegate.buildTable(TableIdentifier.of(dbName, tableName), schema) | ||
.withLocation(location) | ||
.withPartitionSpec(partitionSpec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
location
variable not updated with dbLocation
after fetching it when location
is null or empty
You can modify the code like this:
if (Strings.isNullOrEmpty(location)) {
String dbLocation = getDB(dbName).getLocation();
if (Strings.isNullOrEmpty(dbLocation)) {
throw new StarRocksConnectorException("Failed to find location in database '%s'. Please define the location" +
" when you create table or recreate another database with location." +
" You could execute the SQL command like 'CREATE TABLE <table_name> <columns> " +
"PROPERTIES('location' = '<location>')", dbName);
}
location = dbLocation; // Update location with dbLocation
}
0ad606b
to
215906e
Compare
Signed-off-by: stephen <stephen5217@163.com>
215906e
to
9023fa5
Compare
Quality Gate passedIssues Measures |
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]❌ fail : 7 / 30 (23.33%) file detail
|
@Mergifyio backport branch-3.3 |
@Mergifyio backport branch-3.2 |
✅ Backports have been created
|
✅ Backports have been created
|
Signed-off-by: stephen <stephen5217@163.com> (cherry picked from commit 157a37a)
Signed-off-by: stephen <stephen5217@163.com> (cherry picked from commit 157a37a)
…Rocks#45612) Signed-off-by: stephen <stephen5217@163.com>
Why I'm doing:
What I'm doing:
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: