-
Notifications
You must be signed in to change notification settings - Fork 319
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
[#777] feat(jdbc-mysql): Support for mysql catalog in Gravitino. #786
Conversation
76264dc
to
957c2a8
Compare
@jerryshao The code for the MySQL catalog section can now be reviewed, and the final commit can be reviewed. |
You need to rebase the code. |
...logs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/JdbcColumn.java
Show resolved
Hide resolved
957c2a8
to
87404ba
Compare
Code Coverage Report
Files
|
9e69be0
to
8a99b59
Compare
.../src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.java
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Outdated
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
8a99b59
to
9c10e2b
Compare
...gs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/MysqlCatalog.java
Outdated
Show resolved
Hide resolved
...gs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/MysqlCatalog.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Show resolved
Hide resolved
setProperties.add(((TableChange.SetProperty) change)); | ||
} else if (change instanceof TableChange.RemoveProperty) { | ||
// mysql does not support deleting table attributes, it can be replaced by Set Property | ||
throw new UnsupportedOperationException("Remove property is not supported yet"); |
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 transform RemoveProperty
to SetProperty
in mysql? Gravitino provides a unify interface to user, I think we should do the transformation.
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.
This seems like a mapping relationship, but MySQL itself does not support deleting attribute values. We believe that we should try to maintain the same semantics as MySQL as much as possible
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java
Show resolved
Hide resolved
...on/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java
Outdated
Show resolved
Hide resolved
...mon/src/test/java/com/datastrato/gravitino/catalog/jdbc/operation/SqliteTableOperations.java
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Show resolved
Hide resolved
Generally LGTM, except the above comment. |
#832 I have initiated an issue, and after completing the jdbc related tasks, I will continue with this issue and ultimately write user documentation |
565550a
to
e63b7a3
Compare
...on/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java
Show resolved
Hide resolved
...gs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/MysqlCatalog.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Show resolved
Hide resolved
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...logs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/JdbcColumn.java
Show resolved
Hide resolved
if (StringUtils.isNotEmpty(column.comment())) { | ||
sqlBuilder.append("COMMENT '").append(column.comment()).append("' "); | ||
} | ||
return sqlBuilder; |
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.
How do you support specifying column properties key index, primary key, auto increment?
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.
Added field attributes in line 497, and these attributes will be added
} | ||
String col = updateColumnComment.fieldNames()[0]; | ||
JdbcColumn column = getJdbcColumnFromCreateTable(createTable, col); | ||
column.getProperties().remove(PRIMARY_KEY); |
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.
What's the meaning of this line?
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.
In the syntax of "MODIFY COLUMN", the attribute "PRIMARY KEY" is not supported. Here, only the annotation of the column is modified, so removing this attribute to avoid errors will not remove the "PRIMARY KEY" attribute of the field
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestMysqlDatabaseOperations extends TestMysqlAbstractIT { |
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 you should have E2E test here instead of these UTs. If you have another PR you can do it separately. Otherwise you'd do it here.
* ["ENGINE","=","InnoDB","DEFAULT","CHARSET","=","utf8mb4"] | ||
* @return key-value pairs. For example: {"ENGINE":"InnoDB","DEFAULT CHARSET":"utf8mb4"} | ||
*/ | ||
private static Map<String, String> parseOrderedKeyValuePairs(String[] input) { |
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.
Should you also add some properties as reserved 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.
Will be available in #804 Do these things
Overall, I think the properties part (DB, table, column) doesn't have a clear definition and spec for Gravitino, mostly it directly get from underlying database and put into the properties, which is not so clear here. My thinking is that we should have a unified definitions for all the jdbc database implementations. |
Yes, including in |
...-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/converter/JdbcTypeConverter.java
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Outdated
Show resolved
Hide resolved
...sql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
Show resolved
Hide resolved
...mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlTypeConverter.java
Show resolved
Hide resolved
build.gradle.kts
Outdated
@@ -366,7 +366,8 @@ tasks { | |||
|
|||
val copyCatalogLibAndConfigs by registering(Copy::class) { | |||
dependsOn(":catalogs:catalog-hive:copyLibAndConfig", | |||
":catalogs:catalog-lakehouse-iceberg:copyLibAndConfig") | |||
":catalogs:catalog-lakehouse-iceberg:copyLibAndConfig", | |||
":catalogs:catalog-jdbc-mysql:copyCatalogLibs") |
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.
Do you have a config file for jdbc-mysql catalog like other catalogs?
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.
no
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 we should have to specify catalog level configurations like url, user, password, etc.
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.
My initial thought was that the catalog would expire, and users would need to pass in these attributes through a request. Now, I will add the conf configuration
...dbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/utils/JdbcConnectorUtils.java
Show resolved
Hide resolved
String[] columnSpecs = columnDefinition.getColumnSpecs().toArray(new String[0]); | ||
String columnProperties = String.join(SPACE, columnSpecs); | ||
boolean nullable = !columnProperties.contains(NOT_NULL); | ||
String defaultValue = findPropertiesValue(columnSpecs, DEFAULT); | ||
String comment = findPropertiesValue(columnSpecs, COMMENT); | ||
List<String> properties = getColumnProperties(columnProperties); | ||
Optional.ofNullable(indexGroupByName.get(columnName)).ifPresent(properties::addAll); |
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.
You didn't fix this issue.
@jerryshao The code for the properties of the column will be retained in this PR because we have not exposed the interface for users to use. The properties of the table will be ignored in this PR |
...gs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/MysqlCatalog.java
Show resolved
Hide resolved
efb1400
to
50cc354
Compare
What changes were proposed in this pull request?
We need to support MySQL as the storage protocol for the catalog in Gravetino
Why are the changes needed?
Fix: #777
Does this PR introduce any user-facing change?
NO
How was this patch tested?
Will be completed during integration testing