-
Notifications
You must be signed in to change notification settings - Fork 409
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
[#2571] feat(catalog-jdbc-doris): Add database operations for Doris catalog #2734
Conversation
62d8eb5
to
ec8ea7f
Compare
.../src/main/java/com/datastrato/gravitino/catalog/doris/converter/DorisExceptionConverter.java
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisDatabaseOperations.java
Outdated
Show resolved
Hide resolved
return sqlBuilder.toString(); | ||
} | ||
|
||
try (final Connection connection = this.dataSource.getConnection()) { |
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.
Can we only use one try statement here? It seems excessive.
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.
done.
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.
done
throw new UnsupportedOperationException(); | ||
public JdbcSchema load(String databaseName) throws NoSuchSchemaException { | ||
try (final Connection connection = this.dataSource.getConnection()) { | ||
String query = "SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = ?"; |
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.
We do not suggest using system table information_schema.SCHEMATA
, please refer to method JdbcTableOperations#load
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.
Maybe we can only use information_schema.SCHEMATA
for database information.
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.
@zhoukangcn
We are going to remove all places that depend on system table like #2616
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.
I see. I will update my code when 2616 is merged
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.
done
ae0dfad
to
ec32572
Compare
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.
Overall LGTM
86fce6c
to
a76ad2a
Compare
String databaseName, String comment, Map<String, String> properties) { | ||
if (StringUtils.isNotEmpty(comment)) { | ||
throw new UnsupportedOperationException( | ||
"Doris doesn't support set database comment: " + comment); |
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.
Since Doris supports database properties, should we store the comment in the properties instead of throwing an exception?
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.
BTW, the gravitino.identifier
was stored in the comment, you should extract it and put it into the properties.
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.
Got it, I will update to support comment and gravitino.identifier
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.
@mchades I had update code, store comment in database properties.
In my opinion, it is sufficient to store comments in the attribute with gravitino.identifier
. There is no need to extract it. Do you have any suggestions?
|
||
// Doris does not support setting schema comment, put comment in properties | ||
Map<String, String> newProperties = new HashMap<>(properties); | ||
if (StringUtils.isNotEmpty(comment)) { |
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.
Will the comment be empty?
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.
Thanks for remind. this line has been removed.
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.
LGTM
@SuppressWarnings("FormatStringAnnotation") | ||
@Override | ||
public GravitinoRuntimeException toGravitinoException(SQLException se) { | ||
// TODO: add implementation for doris catalog | ||
int errorCode = se.getErrorCode(); |
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.
cc @xloya For relational storage backend, could we add the similar logic?
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.
I think it's OK, but we may need to add the database type in the error code processing logic, because the error codes defined by different databases may be different for one error. Currently, we could only consider about MySQL.
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.
Maybe you can define a similar interface.
What changes were proposed in this pull request?
Add database operations for Doris catalog
Why are the changes needed?
Fix: #2571
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
UT & IT