diff --git a/catalogs/bundled-catalog/build.gradle.kts b/catalogs/bundled-catalog/build.gradle.kts index 2c8b03f4ed4..dcc88dec00f 100644 --- a/catalogs/bundled-catalog/build.gradle.kts +++ b/catalogs/bundled-catalog/build.gradle.kts @@ -16,6 +16,7 @@ dependencies { implementation(project(":catalogs:catalog-lakehouse-iceberg")) implementation(project(":catalogs:catalog-jdbc-mysql")) implementation(project(":catalogs:catalog-jdbc-postgresql")) + implementation(project(":catalogs:catalog-jdbc-common")) implementation(libs.slf4j.api) } diff --git a/catalogs/bundled-catalog/src/main/java/com/datastrato/catalog/common/ClassProvider.java b/catalogs/bundled-catalog/src/main/java/com/datastrato/catalog/common/ClassProvider.java index a4a917d44bc..f0c1d896a73 100644 --- a/catalogs/bundled-catalog/src/main/java/com/datastrato/catalog/common/ClassProvider.java +++ b/catalogs/bundled-catalog/src/main/java/com/datastrato/catalog/common/ClassProvider.java @@ -11,9 +11,11 @@ import com.datastrato.gravitino.catalog.hive.HiveCatalogPropertiesMeta; import com.datastrato.gravitino.catalog.hive.HiveSchemaPropertiesMetadata; import com.datastrato.gravitino.catalog.hive.HiveTablePropertiesMetadata; +import com.datastrato.gravitino.catalog.jdbc.JdbcTablePropertiesMetadata; import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergCatalogPropertiesMetadata; import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergSchemaPropertiesMetadata; import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergTablePropertiesMetadata; +import com.datastrato.gravitino.catalog.mysql.MysqlTablePropertiesMetadata; import java.util.HashSet; import java.util.Set; @@ -66,7 +68,8 @@ public class ClassProvider { private static final Set> MYSQL_NEED_CLASS = new HashSet>() { { - // TODO + add(MysqlTablePropertiesMetadata.class); + add(JdbcTablePropertiesMetadata.class); } }; diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java index 6d52cc682dd..a54a464143a 100644 --- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java +++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java @@ -10,7 +10,6 @@ import com.datastrato.gravitino.NameIdentifier; import com.datastrato.gravitino.catalog.hive.HiveClientPool; import com.datastrato.gravitino.client.GravitinoMetaLake; -import com.datastrato.gravitino.dto.rel.ColumnDTO; import com.datastrato.gravitino.dto.rel.DistributionDTO; import com.datastrato.gravitino.dto.rel.SortOrderDTO; import com.datastrato.gravitino.dto.rel.expressions.FieldReferenceDTO; @@ -22,6 +21,7 @@ import com.datastrato.gravitino.integration.test.util.AbstractIT; import com.datastrato.gravitino.integration.test.util.GravitinoITUtils; import com.datastrato.gravitino.integration.test.util.ITUtils; +import com.datastrato.gravitino.rel.Column; import com.datastrato.gravitino.rel.Schema; import com.datastrato.gravitino.rel.Table; import com.datastrato.gravitino.rel.expressions.NamedReference; @@ -34,6 +34,8 @@ import com.datastrato.gravitino.rel.expressions.sorts.SortOrders; import com.datastrato.gravitino.rel.expressions.transforms.Transform; import com.datastrato.gravitino.rel.expressions.transforms.Transforms; +import com.datastrato.gravitino.rel.indexes.Index; +import com.datastrato.gravitino.rel.indexes.Indexes; import com.datastrato.gravitino.rel.types.Types; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -522,84 +524,62 @@ private static boolean checkTrinoHasLoaded(String sql, long maxWaitTimeSec) return false; } - private ColumnDTO[] createHiveFullTypeColumns() { - ColumnDTO[] columnDTO = createFullTypeColumns(); + private Column[] createHiveFullTypeColumns() { + Column[] columnDTO = createFullTypeColumns(); Set unsupportedType = Sets.newHashSet("FixedType", "StringType", "TimeType"); // MySQL doesn't support timestamp time zone return Arrays.stream(columnDTO) .filter(c -> !unsupportedType.contains(c.name())) - .toArray(ColumnDTO[]::new); + .toArray(Column[]::new); } - private ColumnDTO[] createMySQLFullTypeColumns() { - ColumnDTO[] columnDTO = createFullTypeColumns(); + private Column[] createMySQLFullTypeColumns() { + Column[] columnDTO = createFullTypeColumns(); Set unsupportedType = Sets.newHashSet("FixedType", "StringType", "TimestampType", "BooleanType"); // MySQL doesn't support timestamp time zone return Arrays.stream(columnDTO) .filter(c -> !unsupportedType.contains(c.name())) - .toArray(ColumnDTO[]::new); + .toArray(Column[]::new); } - private ColumnDTO[] createIcebergFullTypeColumns() { - ColumnDTO[] columnDTO = createFullTypeColumns(); + private Column[] createIcebergFullTypeColumns() { + Column[] columnDTO = createFullTypeColumns(); Set unsupportedType = Sets.newHashSet("ByteType", "ShortType", "VarCharType", "FixedCharType"); return Arrays.stream(columnDTO) .filter(c -> !unsupportedType.contains(c.name())) - .toArray(ColumnDTO[]::new); + .toArray(Column[]::new); } - private ColumnDTO[] createFullTypeColumns() { + private Column[] createFullTypeColumns() { // Generate all types of columns that in class Types - return new ColumnDTO[] { - new ColumnDTO.Builder<>() - .withName("BooleanType") - .withDataType(Types.BooleanType.get()) - .build(), - + return new Column[] { // Int type - new ColumnDTO.Builder<>().withName("ByteType").withDataType(Types.ByteType.get()).build(), - new ColumnDTO.Builder<>().withName("ShortType").withDataType(Types.ShortType.get()).build(), - new ColumnDTO.Builder<>() - .withName("IntegerType") - .withDataType(Types.IntegerType.get()) - .build(), - new ColumnDTO.Builder<>().withName("LongType").withDataType(Types.LongType.get()).build(), + Column.of("BooleanType", Types.BooleanType.get()), + Column.of("ByteType", Types.ByteType.get()), + Column.of("ShortType", Types.ShortType.get()), + Column.of("IntegerType", Types.IntegerType.get()), + Column.of("LongType", Types.LongType.get()), // float type - new ColumnDTO.Builder<>().withName("FloatType").withDataType(Types.FloatType.get()).build(), - new ColumnDTO.Builder<>().withName("DoubleType").withDataType(Types.DoubleType.get()).build(), - new ColumnDTO.Builder<>() - .withName("DecimalType") - .withDataType(Types.DecimalType.of(10, 3)) - .build(), + Column.of("FloatType", Types.FloatType.get()), + Column.of("DoubleType", Types.DoubleType.get()), + Column.of("DecimalType", Types.DecimalType.of(10, 3)), // Date Type - new ColumnDTO.Builder<>().withName("DateType").withDataType(Types.DateType.get()).build(), - new ColumnDTO.Builder<>().withName("TimeType").withDataType(Types.TimeType.get()).build(), - new ColumnDTO.Builder<>() - .withName("TimestampType") - .withDataType(Types.TimestampType.withTimeZone()) - .build(), + Column.of("DateType", Types.DateType.get()), + Column.of("TimeType", Types.TimeType.get()), + Column.of("TimestampType", Types.TimestampType.withTimeZone()), // String Type - new ColumnDTO.Builder<>() - .withName("VarCharType") - .withDataType(Types.VarCharType.of(100)) - .build(), - new ColumnDTO.Builder<>() - .withName("FixedCharType") - .withDataType(Types.FixedCharType.of(100)) - .build(), - new ColumnDTO.Builder<>().withName("StringType").withDataType(Types.StringType.get()).build(), - new ColumnDTO.Builder<>() - .withName("FixedType") - .withDataType(Types.FixedType.of(1000)) - .build(), + Column.of("VarCharType", Types.VarCharType.of(100)), + Column.of("FixedCharType", Types.FixedCharType.of(100)), + Column.of("FixedType", Types.FixedType.of(1000)), + // Binary Type - new ColumnDTO.Builder<>().withName("BinaryType").withDataType(Types.BinaryType.get()).build() + Column.of("BinaryType", Types.BinaryType.get()) // No Interval Type and complex type like map, struct, and list }; } @@ -1174,6 +1154,47 @@ void testMySQLTableCreatedByGravitino() throws InterruptedException { if (!success) { Assertions.fail("Trino fail to load table created by gravitino: " + sql); } + + // Create a table with primary key + Column[] columnDTOS = createMySQLFullTypeColumns(); + columnDTOS = + Arrays.stream(columnDTOS) + .map( + c -> { + if ("IntegerType".equals(c.name())) { + return Column.of(c.name(), c.dataType(), "", false, true, null); + } + return c; + }) + .toArray(Column[]::new); + + tableName = GravitinoITUtils.genRandomName("mysql_table_with_primary").toLowerCase(); + catalog + .asTableCatalog() + .createTable( + NameIdentifier.of(metalakeName, catalogName, schemaName, tableName), + columnDTOS, + "Created by gravitino client", + ImmutableMap.builder().build(), + new Transform[0], + Distributions.NONE, + new SortOrder[0], + new Index[] { + Indexes.createMysqlPrimaryKey(new String[][] {new String[] {"IntegerType"}}) + }); + sql = + String.format( + "show create table \"%s.%s\".%s.%s", metalakeName, catalogName, schemaName, tableName); + + success = checkTrinoHasLoaded(sql, 30); + if (!success) { + Assertions.fail("Trino fail to load table created by gravitino: " + sql); + } + data = containerSuite.getTrinoContainer().executeQuerySQL(sql).get(0).get(0); + + Assertions.assertTrue(data.contains("engine = 'InnoDB'")); + Assertions.assertTrue( + data.contains("integertype integer NOT NULL WITH ( auto_increment = true )")); } @Test diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql index 24e4baf7a46..3b2c9487606 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.sql @@ -5,6 +5,8 @@ CREATE TABLE "test.gt_mysql".gt_db1.tb01 ( salary int ); +show create table "test.gt_mysql".gt_db1.tb01; + drop table "test.gt_mysql".gt_db1.tb01; drop schema "test.gt_mysql".gt_db1; \ No newline at end of file diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt index 2862f23f236..21188b9fa71 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00000_create_table.txt @@ -2,6 +2,15 @@ CREATE SCHEMA CREATE TABLE +"CREATE TABLE ""test.gt_mysql"".gt_db1.tb01 ( + name varchar(200), + salary integer +) +COMMENT '' +WITH ( + engine = 'InnoDB' +)" + DROP TABLE DROP SCHEMA diff --git a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt index 9a75e64d267..6fa0269d5ba 100644 --- a/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt +++ b/integration-test/src/test/resources/trino-ci-testset/testsets/jdbc-mysql/00002_alter_table.txt @@ -16,7 +16,10 @@ DROP COLUMN name varchar(200), salary integer ) -COMMENT ''" +COMMENT '' +WITH ( + engine = 'InnoDB' +)" SET COLUMN TYPE @@ -24,7 +27,10 @@ SET COLUMN TYPE name varchar(200), salary bigint ) -COMMENT ''" +COMMENT '' +WITH ( + engine = 'InnoDB' +)" ADD COLUMN @@ -33,7 +39,10 @@ ADD COLUMN salary bigint, city varchar(50) COMMENT 'aaa' ) -COMMENT ''" +COMMENT '' +WITH ( + engine = 'InnoDB' +)" ADD COLUMN @@ -43,7 +52,10 @@ ADD COLUMN city varchar(50) COMMENT 'aaa', age integer NOT NULL COMMENT 'age of users' ) -COMMENT ''" +COMMENT '' +WITH ( + engine = 'InnoDB' +)" ADD COLUMN @@ -54,7 +66,10 @@ ADD COLUMN age integer NOT NULL COMMENT 'age of users', address varchar(200) NOT NULL COMMENT 'address of users' ) -COMMENT ''" +COMMENT '' +WITH ( + engine = 'InnoDB' +)" DROP TABLE diff --git a/trino-connector/build.gradle.kts b/trino-connector/build.gradle.kts index 07da2482729..95edb738ec4 100644 --- a/trino-connector/build.gradle.kts +++ b/trino-connector/build.gradle.kts @@ -20,6 +20,7 @@ dependencies { implementation(libs.guava) implementation(libs.httpclient5) implementation(libs.commons.lang3) + implementation(libs.commons.collections4) implementation(libs.trino.spi) { exclude("org.apache.logging.log4j") } diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java index b77a1072489..04462fdb3c3 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/CatalogConnectorMetadataAdapter.java @@ -89,8 +89,11 @@ public GravitinoTable createTable(ConnectorTableMetadata tableMetadata) { dataTypeTransformer.getGravitinoType(column.getType()), i, column.getComment(), - column.isNullable())); + column.isNullable(), + false, + column.getProperties())); } + return new GravitinoTable(schemaName, tableName, columns, comment, properties); } @@ -114,6 +117,7 @@ public ColumnMetadata getColumnMetadata(GravitinoColumn column) { .setComment(Optional.ofNullable(column.getComment())) .setNullable(column.isNullable()) .setHidden(column.isHidden()) + .setProperties(column.getProperties()) .build(); } @@ -172,6 +176,8 @@ public GravitinoColumn createColumn(ColumnMetadata column) { dataTypeTransformer.getGravitinoType(column.getType()), -1, column.getComment(), - column.isNullable()); + column.isNullable(), + false, + column.getProperties()); } } diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/PropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/PropertyConverter.java deleted file mode 100644 index 476b2cfc913..00000000000 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/PropertyConverter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2023 Datastrato Pvt Ltd. - * This software is licensed under the Apache License version 2. - */ - -package com.datastrato.gravitino.trino.connector.catalog; - -import com.datastrato.gravitino.catalog.PropertyEntry; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; -import java.util.HashMap; -import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Transforming between gravitino schema/table/column property and Trino property. */ -@Deprecated -public abstract class PropertyConverter { - - private static final Logger LOG = LoggerFactory.getLogger(PropertyConverter.class); - - /** - * Convert Trino properties to Gravitino properties. It will return a map that holds the mapping - * between Trino and gravitino properties. - * - * @return a map that holds the mapping from Trino to Gravitino properties. - */ - public abstract TreeBidiMap engineToGravitino(); - - /** Convert Trino properties to Gravitino properties. */ - public Map fromGravitinoProperties(Map properties) { - Map trinoProperties = new HashMap<>(); - Map gravitinoToTrinoMapping = engineToGravitino().inverseBidiMap(); - for (Map.Entry entry : properties.entrySet()) { - String trinoKey = gravitinoToTrinoMapping.get(entry.getKey()); - if (trinoKey != null) { - trinoProperties.put(trinoKey, entry.getValue()); - } else { - LOG.warn("Property {} is not supported in Trino", trinoKey); - } - } - return trinoProperties; - } - - /** Convert Gravitino properties to Trino properties. */ - public Map toGravitinoProperties(Map properties) { - Map gravitinoProperties = new HashMap<>(); - Map trinoToGravitinoMapping = engineToGravitino(); - for (Map.Entry entry : properties.entrySet()) { - String gravitinoKey = trinoToGravitinoMapping.get(entry.getKey()); - if (gravitinoKey != null) { - gravitinoProperties.put(gravitinoKey, entry.getValue()); - } else { - LOG.warn("Property {} is not supported in Gravitino", gravitinoKey); - } - } - return gravitinoProperties; - } - - public abstract Map> gravitinoPropertyMeta(); -} diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveCatalogPropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveCatalogPropertyConverter.java index 71812d5f647..d4622a6ddce 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveCatalogPropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveCatalogPropertyConverter.java @@ -7,9 +7,9 @@ import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.catalog.PropertyEntry; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java index a220d9460d2..e1fa07a2d06 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java @@ -22,39 +22,54 @@ /** Implementation of {@link HasPropertyMeta} for Hive catalog. */ public class HivePropertyMeta implements HasPropertyMeta { + static final String HIVE_SCHEMA_LOCATION = "location"; + private static final List> SCHEMA_PROPERTY_META = ImmutableList.of( - stringProperty("location", "Hive storage location for the schema", null, false)); + stringProperty( + HIVE_SCHEMA_LOCATION, "Hive storage location for the schema", null, false)); - public static final String HIVE_PARTITION_KEY = "partitioned_by"; - public static final String HIVE_BUCKET_KEY = "bucketed_by"; - public static final String HIVE_BUCKET_COUNT_KEY = "bucket_count"; - public static final String HIVE_SORT_ORDER_KEY = "sorted_by"; + static final String HIVE_TABLE_FORMAT = "format"; + static final String HIVE_TABLE_TOTAL_SIZE = "total_size"; + static final String HIVE_TABLE_NUM_FILES = "num_files"; + static final String HIVE_TABLE_EXTERNAL = "external"; + static final String HIVE_TABLE_LOCATION = "location"; + static final String HIVE_TABLE_TYPE = "table_type"; + static final String HIVE_TABLE_INPUT_FORMAT = "input_format"; + static final String HIVE_TABLE_OUTPUT_FORMAT = "output_format"; + static final String HIVE_TABLE_SERDE_LIB = "serde_lib"; + static final String HIVE_TABLE_SERDE_NAME = "serde_name"; + static final String HIVE_PARTITION_KEY = "partitioned_by"; + static final String HIVE_BUCKET_KEY = "bucketed_by"; + static final String HIVE_BUCKET_COUNT_KEY = "bucket_count"; + static final String HIVE_SORT_ORDER_KEY = "sorted_by"; private static final List> TABLE_PROPERTY_META = ImmutableList.of( - stringProperty("format", "Hive storage format for the table", "TEXTFILE", false), - stringProperty("total_size", "total size of the table", null, false), - stringProperty("num_files", "number of files", null, false), - stringProperty("external", "Indicate whether it is an external table", null, true), - stringProperty("location", "HDFS location for table storage", null, false), - stringProperty("table_type", "The type of Hive table", null, false), + stringProperty(HIVE_TABLE_FORMAT, "Hive storage format for the table", "TEXTFILE", false), + stringProperty(HIVE_TABLE_TOTAL_SIZE, "total size of the table", null, false), + stringProperty(HIVE_TABLE_NUM_FILES, "number of files", null, false), stringProperty( - "input_format", + HIVE_TABLE_EXTERNAL, "Indicate whether it is an external table", null, true), + stringProperty(HIVE_TABLE_LOCATION, "HDFS location for table storage", null, false), + stringProperty(HIVE_TABLE_TYPE, "The type of Hive table", null, false), + stringProperty( + HIVE_TABLE_INPUT_FORMAT, "The input format class for the table", "org.apache.hadoop.mapred.TextInputFormat", false), stringProperty( - "output_format", + HIVE_TABLE_OUTPUT_FORMAT, "The output format class for the table", "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", false), stringProperty( - "serde_lib", + HIVE_TABLE_SERDE_LIB, "The serde library class for the table", "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe", false), - stringProperty("serde_name", "Name of the serde, table name by default", null, false), + stringProperty( + HIVE_TABLE_SERDE_NAME, "Name of the serde, table name by default", null, false), new PropertyMetadata<>( HIVE_PARTITION_KEY, "Partition columns", diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveSchemaPropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveSchemaPropertyConverter.java index 83540731877..4c2adc56c81 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveSchemaPropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveSchemaPropertyConverter.java @@ -4,13 +4,15 @@ */ package com.datastrato.gravitino.trino.connector.catalog.hive; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_SCHEMA_LOCATION; + import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.catalog.BasePropertiesMetadata; import com.datastrato.gravitino.catalog.PropertyEntry; import com.datastrato.gravitino.catalog.hive.HiveSchemaPropertiesMetadata; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class HiveSchemaPropertyConverter extends PropertyConverter { private final BasePropertiesMetadata hiveSchemaPropertiesMetadata = @@ -21,7 +23,7 @@ public class HiveSchemaPropertyConverter extends PropertyConverter { private static final TreeBidiMap TRINO_KEY_TO_GRAVITINO_KEY = new TreeBidiMap<>( new ImmutableMap.Builder() - .put("location", HiveSchemaPropertiesMetadata.LOCATION) + .put(HIVE_SCHEMA_LOCATION, HiveSchemaPropertiesMetadata.LOCATION) .build()); @Override diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveTablePropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveTablePropertyConverter.java index 48271e874ab..27433a16064 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveTablePropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HiveTablePropertyConverter.java @@ -4,14 +4,25 @@ */ package com.datastrato.gravitino.trino.connector.catalog.hive; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_EXTERNAL; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_FORMAT; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_INPUT_FORMAT; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_LOCATION; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_NUM_FILES; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_OUTPUT_FORMAT; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_SERDE_LIB; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_SERDE_NAME; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_TOTAL_SIZE; +import static com.datastrato.gravitino.trino.connector.catalog.hive.HivePropertyMeta.HIVE_TABLE_TYPE; + import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.catalog.BasePropertiesMetadata; import com.datastrato.gravitino.catalog.PropertyEntry; import com.datastrato.gravitino.catalog.hive.HiveTablePropertiesMetadata; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class HiveTablePropertyConverter extends PropertyConverter { private final BasePropertiesMetadata hiveTablePropertiesMetadata = @@ -22,16 +33,16 @@ public class HiveTablePropertyConverter extends PropertyConverter { static final TreeBidiMap TRINO_KEY_TO_GRAVITINO_KEY = new TreeBidiMap<>( new ImmutableMap.Builder() - .put("format", HiveTablePropertiesMetadata.FORMAT) - .put("total_size", HiveTablePropertiesMetadata.TOTAL_SIZE) - .put("num_files", HiveTablePropertiesMetadata.NUM_FILES) - .put("external", HiveTablePropertiesMetadata.EXTERNAL) - .put("location", HiveTablePropertiesMetadata.LOCATION) - .put("table_type", HiveTablePropertiesMetadata.TABLE_TYPE) - .put("input_format", HiveTablePropertiesMetadata.INPUT_FORMAT) - .put("output_format", HiveTablePropertiesMetadata.OUTPUT_FORMAT) - .put("serde_lib", HiveTablePropertiesMetadata.SERDE_LIB) - .put("serde_name", HiveTablePropertiesMetadata.SERDE_NAME) + .put(HIVE_TABLE_FORMAT, HiveTablePropertiesMetadata.FORMAT) + .put(HIVE_TABLE_TOTAL_SIZE, HiveTablePropertiesMetadata.TOTAL_SIZE) + .put(HIVE_TABLE_NUM_FILES, HiveTablePropertiesMetadata.NUM_FILES) + .put(HIVE_TABLE_EXTERNAL, HiveTablePropertiesMetadata.EXTERNAL) + .put(HIVE_TABLE_LOCATION, HiveTablePropertiesMetadata.LOCATION) + .put(HIVE_TABLE_TYPE, HiveTablePropertiesMetadata.TABLE_TYPE) + .put(HIVE_TABLE_INPUT_FORMAT, HiveTablePropertiesMetadata.INPUT_FORMAT) + .put(HIVE_TABLE_OUTPUT_FORMAT, HiveTablePropertiesMetadata.OUTPUT_FORMAT) + .put(HIVE_TABLE_SERDE_LIB, HiveTablePropertiesMetadata.SERDE_LIB) + .put(HIVE_TABLE_SERDE_NAME, HiveTablePropertiesMetadata.SERDE_NAME) .build()); @Override diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java index e7bd2ed3a26..9da409ea59c 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java @@ -7,7 +7,6 @@ import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.catalog.PropertyEntry; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.datastrato.gravitino.trino.connector.GravitinoErrorCode; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; @@ -15,6 +14,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class IcebergCatalogPropertyConverter extends PropertyConverter { diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java index 169cc75ec50..e990c57deeb 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergMetadataAdapter.java @@ -106,7 +106,9 @@ public GravitinoTable createTable(ConnectorTableMetadata tableMetadata) { dataTypeTransformer.getGravitinoType(column.getType()), i, column.getComment(), - column.isNullable())); + column.isNullable(), + false, + column.getProperties())); } GravitinoTable gravitinoTable = new GravitinoTable(schemaName, tableName, columns, comment, properties); diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergSchemaPropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergSchemaPropertyConverter.java index a1dee3ee757..8da6ca97d5f 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergSchemaPropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergSchemaPropertyConverter.java @@ -9,9 +9,9 @@ import com.datastrato.gravitino.catalog.BasePropertiesMetadata; import com.datastrato.gravitino.catalog.PropertyEntry; import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergSchemaPropertiesMetadata; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class IcebergSchemaPropertyConverter extends PropertyConverter { diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergTablePropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergTablePropertyConverter.java index 77ff158110c..58ef571f1b8 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergTablePropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/iceberg/IcebergTablePropertyConverter.java @@ -12,10 +12,10 @@ import com.datastrato.gravitino.catalog.BasePropertiesMetadata; import com.datastrato.gravitino.catalog.PropertyEntry; import com.datastrato.gravitino.catalog.lakehouse.iceberg.IcebergTablePropertiesMetadata; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class IcebergTablePropertyConverter extends PropertyConverter { diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/JDBCCatalogPropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/JDBCCatalogPropertyConverter.java index 6f296fb362b..4e597f09286 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/JDBCCatalogPropertyConverter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/JDBCCatalogPropertyConverter.java @@ -7,11 +7,11 @@ import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.catalog.PropertyEntry; -import com.datastrato.gravitino.shaded.org.apache.commons.collections4.bidimap.TreeBidiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import java.util.Map; import java.util.Set; +import org.apache.commons.collections4.bidimap.TreeBidiMap; public class JDBCCatalogPropertyConverter extends PropertyConverter { diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLConnectorAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLConnectorAdapter.java index 90cf45c9abb..ad84f397583 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLConnectorAdapter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLConnectorAdapter.java @@ -9,9 +9,12 @@ import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorAdapter; import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter; +import com.datastrato.gravitino.trino.connector.catalog.HasPropertyMeta; import com.datastrato.gravitino.trino.connector.catalog.jdbc.JDBCCatalogPropertyConverter; import com.datastrato.gravitino.trino.connector.metadata.GravitinoCatalog; +import io.trino.spi.session.PropertyMetadata; import java.util.HashMap; +import java.util.List; import java.util.Map; /** Transforming MySQL connector configuration and components into Gravitino connector. */ @@ -19,9 +22,11 @@ public class MySQLConnectorAdapter implements CatalogConnectorAdapter { private final PropertyConverter catalogConverter; private static int version = 0; + private final HasPropertyMeta propertyMetadata; public MySQLConnectorAdapter() { this.catalogConverter = new JDBCCatalogPropertyConverter(); + this.propertyMetadata = new MySQLPropertyMeta(); } public Map buildInternalConnectorConfig(GravitinoCatalog catalog) @@ -41,4 +46,14 @@ public CatalogConnectorMetadataAdapter getMetadataAdapter() { // TODO yuhui Need to improve schema table and column properties return new MySQLMetadataAdapter(getSchemaProperties(), getTableProperties(), emptyList()); } + + @Override + public List> getTableProperties() { + return propertyMetadata.getTablePropertyMetadata(); + } + + @Override + public List> getColumnProperties() { + return propertyMetadata.getColumnPropertyMetadata(); + } } diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLMetadataAdapter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLMetadataAdapter.java index 9411a9f6f64..48f9b795eb1 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLMetadataAdapter.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLMetadataAdapter.java @@ -4,18 +4,86 @@ */ package com.datastrato.gravitino.trino.connector.catalog.jdbc.mysql; +import com.datastrato.catalog.property.PropertyConverter; import com.datastrato.gravitino.trino.connector.catalog.CatalogConnectorMetadataAdapter; +import com.datastrato.gravitino.trino.connector.metadata.GravitinoColumn; +import com.datastrato.gravitino.trino.connector.metadata.GravitinoTable; +import com.google.common.collect.Maps; +import io.trino.spi.connector.ColumnMetadata; +import io.trino.spi.connector.ConnectorTableMetadata; import io.trino.spi.session.PropertyMetadata; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Optional; /** Transforming gravitino MySQL metadata to trino. */ public class MySQLMetadataAdapter extends CatalogConnectorMetadataAdapter { + private final PropertyConverter tableConverter; + public MySQLMetadataAdapter( List> schemaProperties, List> tableProperties, List> columnProperties) { super(schemaProperties, tableProperties, columnProperties, new MySQLDataTypeTransformer()); + this.tableConverter = new MySQLTablePropertyConverter(); + } + + @Override + public Map toGravitinoTableProperties(Map properties) { + Map stringMap = tableConverter.engineToGravitinoProperties(properties); + return super.toGravitinoTableProperties(stringMap); + } + + @Override + public Map toTrinoTableProperties(Map properties) { + Map objectMap = tableConverter.gravitinoToEngineProperties(properties); + return super.toTrinoTableProperties(objectMap); + } + + /** Transform trino ConnectorTableMetadata to gravitino table metadata */ + public GravitinoTable createTable(ConnectorTableMetadata tableMetadata) { + String tableName = tableMetadata.getTableSchema().getTable().getTableName(); + String schemaName = tableMetadata.getTableSchema().getTable().getSchemaName(); + String comment = tableMetadata.getComment().orElse(""); + Map properties = toGravitinoTableProperties(tableMetadata.getProperties()); + + List columns = new ArrayList<>(); + for (int i = 0; i < tableMetadata.getColumns().size(); i++) { + ColumnMetadata column = tableMetadata.getColumns().get(i); + boolean autoIncrement = + (boolean) column.getProperties().getOrDefault(MySQLPropertyMeta.AUTO_INCREMENT, false); + + columns.add( + new GravitinoColumn( + column.getName(), + dataTypeTransformer.getGravitinoType(column.getType()), + i, + column.getComment(), + column.isNullable(), + autoIncrement, + column.getProperties())); + } + + return new GravitinoTable(schemaName, tableName, columns, comment, properties); + } + + @Override + public ColumnMetadata getColumnMetadata(GravitinoColumn column) { + Map propertyMap = Maps.newHashMap(column.getProperties()); + if (column.isAutoIncrement()) { + propertyMap.put(MySQLPropertyMeta.AUTO_INCREMENT, true); + } + + return ColumnMetadata.builder() + .setName(column.getName()) + .setType(dataTypeTransformer.getTrinoType(column.getType())) + .setComment(Optional.ofNullable(column.getComment())) + .setNullable(column.isNullable()) + .setHidden(column.isHidden()) + .setProperties(propertyMap) + .build(); } } diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLPropertyMeta.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLPropertyMeta.java new file mode 100644 index 00000000000..43d36b5943a --- /dev/null +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLPropertyMeta.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Datastrato Pvt Ltd. + * This software is licensed under the Apache License version 2. + */ + +package com.datastrato.gravitino.trino.connector.catalog.jdbc.mysql; + +import static io.trino.spi.session.PropertyMetadata.booleanProperty; +import static io.trino.spi.session.PropertyMetadata.stringProperty; + +import com.datastrato.gravitino.trino.connector.catalog.HasPropertyMeta; +import com.google.common.collect.ImmutableList; +import io.trino.spi.session.PropertyMetadata; +import java.util.List; + +public class MySQLPropertyMeta implements HasPropertyMeta { + + static final String TABLE_ENGINE = "engine"; + static final String TABLE_AUTO_INCREMENT_OFFSET = "auto_increment_offset"; + + private static final List> TABLE_PROPERTY_META = + ImmutableList.of( + stringProperty(TABLE_ENGINE, "The engine that MySQL table uses", "InnoDB", false), + stringProperty( + TABLE_AUTO_INCREMENT_OFFSET, "The auto increment offset for the table", null, false)); + + public static final String AUTO_INCREMENT = "auto_increment"; + private static final List> COLUMN_PROPERTY_META = + ImmutableList.of(booleanProperty(AUTO_INCREMENT, "The auto increment column", false, false)); + + @Override + public List> getTablePropertyMetadata() { + return TABLE_PROPERTY_META; + } + + @Override + public List> getColumnPropertyMetadata() { + return COLUMN_PROPERTY_META; + } +} diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLTablePropertyConverter.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLTablePropertyConverter.java new file mode 100644 index 00000000000..50ddef20d6c --- /dev/null +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/jdbc/mysql/MySQLTablePropertyConverter.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Datastrato Pvt Ltd. + * This software is licensed under the Apache License version 2. + */ + +package com.datastrato.gravitino.trino.connector.catalog.jdbc.mysql; + +import static com.datastrato.gravitino.trino.connector.catalog.jdbc.mysql.MySQLPropertyMeta.TABLE_AUTO_INCREMENT_OFFSET; +import static com.datastrato.gravitino.trino.connector.catalog.jdbc.mysql.MySQLPropertyMeta.TABLE_ENGINE; + +import com.datastrato.catalog.property.PropertyConverter; +import com.datastrato.gravitino.catalog.BasePropertiesMetadata; +import com.datastrato.gravitino.catalog.PropertyEntry; +import com.datastrato.gravitino.catalog.mysql.MysqlTablePropertiesMetadata; +import com.datastrato.gravitino.shaded.com.google.common.collect.ImmutableMap; +import com.google.common.annotations.VisibleForTesting; +import java.util.Map; +import org.apache.commons.collections4.bidimap.TreeBidiMap; + +public class MySQLTablePropertyConverter extends PropertyConverter { + + private final BasePropertiesMetadata mysqlTablePropertiesMetadata = + new MysqlTablePropertiesMetadata(); + + // TODO (yuqi) add more properties + @VisibleForTesting + static final TreeBidiMap TRINO_KEY_TO_GRAVITINO_KEY = + new TreeBidiMap<>( + new ImmutableMap.Builder() + .put(TABLE_ENGINE, MysqlTablePropertiesMetadata.GRAVITINO_ENGINE_KEY) + .put( + TABLE_AUTO_INCREMENT_OFFSET, + MysqlTablePropertiesMetadata.GRAVITINO_AUTO_INCREMENT_OFFSET_KEY) + .build()); + + @Override + public Map engineToGravitinoMapping() { + return TRINO_KEY_TO_GRAVITINO_KEY; + } + + @Override + public Map> gravitinoPropertyMeta() { + return mysqlTablePropertiesMetadata.propertyEntries(); + } +} diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoColumn.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoColumn.java index 625532efe2f..a1170c675a2 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoColumn.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoColumn.java @@ -6,6 +6,7 @@ import com.datastrato.gravitino.rel.Column; import com.datastrato.gravitino.rel.types.Type; +import com.google.common.collect.ImmutableMap; import java.util.Map; /** Help Gravitino connector access ColumnMetadata from gravitino client. */ @@ -15,25 +16,49 @@ public final class GravitinoColumn { private final int index; private final String comment; private final boolean nullable; + private final boolean autoIncrement; + + // Column properties + private final Map properties; public GravitinoColumn(Column column, int columnIndex) { - this(column.name(), column.dataType(), columnIndex, column.comment(), column.nullable()); + this( + column.name(), + column.dataType(), + columnIndex, + column.comment(), + column.nullable(), + column.autoIncrement(), + ImmutableMap.of()); } - public GravitinoColumn(String name, Type dataType, int index, String comment, boolean nullable) { + public GravitinoColumn( + String name, + Type dataType, + int index, + String comment, + boolean nullable, + boolean autoIncrement, + Map properties) { this.name = name; this.dataType = dataType; this.index = index; this.comment = comment; this.nullable = nullable; + this.autoIncrement = autoIncrement; + this.properties = properties; + } + + public GravitinoColumn(String name, Type dataType, int index, String comment, boolean nullable) { + this(name, dataType, index, comment, nullable, false, ImmutableMap.of()); } public int getIndex() { return index; } - public Map getProperties() { - return null; + public Map getProperties() { + return properties; } public String getName() { @@ -55,4 +80,8 @@ public boolean isNullable() { public boolean isHidden() { return false; } + + public boolean isAutoIncrement() { + return autoIncrement; + } } diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoTable.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoTable.java index 5408b8116a3..c13ed55da04 100644 --- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoTable.java +++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/metadata/GravitinoTable.java @@ -92,13 +92,14 @@ public List getColumns() { public Column[] getRawColumns() { Column[] gravitinoColumns = new Column[columns.size()]; for (int i = 0; i < columns.size(); i++) { + GravitinoColumn column = columns.get(i); gravitinoColumns[i] = Column.of( - columns.get(i).getName(), - columns.get(i).getType(), - columns.get(i).getComment(), - columns.get(i).isNullable(), - false, + column.getName(), + column.getType(), + column.getComment(), + column.isNullable(), + column.isAutoIncrement(), null); } return gravitinoColumns;