yuqi1129 commented on code in PR #7810:
URL: https://github.com/apache/gravitino/pull/7810#discussion_r2241450794


##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/jdbc/mysql/MySQLPropertyMeta.java:
##########
@@ -79,4 +86,40 @@ public List<PropertyMetadata<?>> getTablePropertyMetadata() {
   public List<PropertyMetadata<?>> getColumnPropertyMetadata() {
     return COLUMN_PROPERTY_META;
   }
+
+  /**
+   * Extract primary key from table properties
+   *
+   * @param tableProperties table properties
+   * @return primary key list
+   */
+  public static Set<String> getPrimaryKey(Map<String, Object> tableProperties) 
{
+    requireNonNull(tableProperties, "tableProperties is null");

Review Comment:
   You'd better use `Precondition.checkArguement` as `requireNonNull` will 
throw NPE, which sounds quite terrible.



##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/jdbc/mysql/MySQLPropertyMeta.java:
##########
@@ -79,4 +86,40 @@ public List<PropertyMetadata<?>> getTablePropertyMetadata() {
   public List<PropertyMetadata<?>> getColumnPropertyMetadata() {
     return COLUMN_PROPERTY_META;
   }
+
+  /**
+   * Extract primary key from table properties
+   *
+   * @param tableProperties table properties
+   * @return primary key list
+   */
+  public static Set<String> getPrimaryKey(Map<String, Object> tableProperties) 
{
+    requireNonNull(tableProperties, "tableProperties is null");
+    return ImmutableSet.copyOf((List<String>) 
tableProperties.get(TABLE_PRIMARY_KEY));
+  }
+
+  /**
+   * Extract unique key from table properties
+   *
+   * @param tableProperties table properties
+   * @return unique key list
+   */
+  public static Map<String, Set<String>> getUniqueKey(Map<String, Object> 
tableProperties) {
+    requireNonNull(tableProperties, "tableProperties is null");
+    List<String> uniqueKeyList = (List<String>) 
tableProperties.get(TABLE_UNIQUE_KEY);

Review Comment:
   Is it okay that `TABLE_UNIQUE_KEY` does not exist in `tableProperties`?



##########
docs/trino-connector/catalog-mysql.md:
##########
@@ -16,7 +16,35 @@ To connect to MySQL, you need:
 
 ## Create table
 
-At present, the Apache Gravitino Trino connector only supports basic MySQL 
table creation statements, which involve fields, null allowances, and comments. 
However, it does not support advanced features like primary keys, indexes, 
default values, and auto-increment.
+At present, the Apache Gravitino Trino connector only supports basic MySQL 
table creation statements, which involve fields, null allowances, comments, 
primary keys and indexes. However, it does not support advanced features like 
default values, and auto-increment.
+
+The following are supported MySQL table properties:
+
+| Property name                      | Type   | Default Value  | Description   
                                                                                
                                          | Required | Since Version |
+|------------------------------------|--------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------|----------|---------------|
+| engine                             | string | InnoDB         | The engine 
that MySQL table uses.                                                          
                                             | No       | 0.4.0         |
+| auto_increment_offset              | string | (none)         | The auto 
increment offset for the table.                                                 
                                               | No       | 0.4.0         |
+| primary_key                        | list   | (none)         | The primary 
keys for the table, can choose multi columns as the table primary key. All key 
columns must be defined as `NOT NULL`.       | No       | 1.0.0         |
+| unique_key                         | list   | (none)         | The unique 
keys for the table, can choose multi columns for multi unique key. Each unique 
key should be defined as `keyName:col1,col2`. | No       | 1.0.0         |
+
+You can use the following sql to create table with primary keys and indexes.

Review Comment:
   sql -> SQL



-- 
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]

Reply via email to