Skip to content
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

Merged
merged 5 commits into from
Apr 7, 2024

Conversation

zhoukangcn
Copy link
Contributor

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

@zhoukangcn zhoukangcn force-pushed the f-2571 branch 2 times, most recently from 62d8eb5 to ec8ea7f Compare March 29, 2024 13:45
@zhoukangcn
Copy link
Contributor Author

@yuqi1129 @mchades Please help to review this PR, thanks

return sqlBuilder.toString();
}

try (final Connection connection = this.dataSource.getConnection()) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor Author

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 = ?";
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zhoukangcn zhoukangcn force-pushed the f-2571 branch 6 times, most recently from ae0dfad to ec32572 Compare April 2, 2024 13:07
@zhoukangcn zhoukangcn closed this Apr 2, 2024
@zhoukangcn zhoukangcn reopened this Apr 2, 2024
Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

@zhoukangcn zhoukangcn force-pushed the f-2571 branch 2 times, most recently from 86fce6c to a76ad2a Compare April 3, 2024 10:13
String databaseName, String comment, Map<String, String> properties) {
if (StringUtils.isNotEmpty(comment)) {
throw new UnsupportedOperationException(
"Doris doesn't support set database comment: " + comment);
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mchades mchades merged commit 5348669 into apache:main Apr 7, 2024
27 checks passed
@SuppressWarnings("FormatStringAnnotation")
@Override
public GravitinoRuntimeException toGravitinoException(SQLException se) {
// TODO: add implementation for doris catalog
int errorCode = se.getErrorCode();
Copy link
Contributor

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?

Copy link
Contributor

@xloya xloya Apr 7, 2024

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.

Copy link
Contributor

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.

@zhoukangcn zhoukangcn deleted the f-2571 branch April 7, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] Add database operations for Doris Catalog
5 participants