FANNG1 commented on code in PR #5818: URL: https://github.com/apache/gravitino/pull/5818#discussion_r1912739234
########## flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/paimon/FlinkPaimonCatalogIT.java: ########## @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.flink.connector.integration.test.paimon; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.nio.file.Path; +import java.util.Map; +import org.apache.gravitino.Catalog; +import org.apache.gravitino.catalog.lakehouse.paimon.PaimonConstants; +import org.apache.gravitino.flink.connector.integration.test.FlinkCommonIT; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +// @Tag("gravitino-docker-test") Review Comment: add the tag here? ########## spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.java: ########## @@ -42,14 +41,7 @@ public static PaimonPropertiesConverter getInstance() { @Override public Map<String, String> toSparkCatalogProperties(Map<String, String> properties) { Preconditions.checkArgument(properties != null, "Paimon Catalog properties should not be null"); - Map<String, String> all = PaimonPropertiesUtils.toPaimonCatalogProperties(properties); Review Comment: why removing the check here? ########## flink-connector/flink/src/main/java/org/apache/gravitino/flink/connector/paimon/PaimonPropertiesConverter.java: ########## @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.gravitino.flink.connector.paimon; + +import com.google.common.collect.Maps; +import java.util.Map; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.table.catalog.CommonCatalogOptions; +import org.apache.gravitino.catalog.lakehouse.paimon.PaimonConstants; +import org.apache.gravitino.catalog.lakehouse.paimon.PaimonPropertiesUtils; +import org.apache.gravitino.flink.connector.PropertiesConverter; +import org.apache.paimon.catalog.FileSystemCatalogFactory; + +public class PaimonPropertiesConverter implements PropertiesConverter { + + public static final PaimonPropertiesConverter INSTANCE = new PaimonPropertiesConverter(); + + private PaimonPropertiesConverter() {} + + @Override + public Map<String, String> toGravitinoCatalogProperties(Configuration flinkConf) { + Map<String, String> gravitinoProperties = Maps.newHashMap(); + Map<String, String> flinkConfMap = flinkConf.toMap(); + for (Map.Entry<String, String> entry : flinkConfMap.entrySet()) { + String gravitinoKey = + PaimonPropertiesUtils.PAIMON_CATALOG_CONFIG_TO_GRAVITINO.get(entry.getKey()); + if (gravitinoKey != null) { + gravitinoProperties.put(gravitinoKey, entry.getValue()); + } else if (!entry.getKey().startsWith(FLINK_PROPERTY_PREFIX)) { + gravitinoProperties.put(FLINK_PROPERTY_PREFIX + entry.getKey(), entry.getValue()); + } else { + gravitinoProperties.put(entry.getKey(), entry.getValue()); + } + } + gravitinoProperties.put( + PaimonConstants.CATALOG_BACKEND, + flinkConfMap.getOrDefault(PaimonConstants.METASTORE, FileSystemCatalogFactory.IDENTIFIER)); + return gravitinoProperties; + } + + @Override + public Map<String, String> toFlinkCatalogProperties(Map<String, String> gravitinoProperties) { + Map<String, String> flinkCatalogProperties = Maps.newHashMap(); + flinkCatalogProperties.put( + CommonCatalogOptions.CATALOG_TYPE.key(), GravitinoPaimonCatalogFactoryOptions.IDENTIFIER); + gravitinoProperties.forEach( + (key, value) -> { + String flinkConfigKey = key; + if (key.startsWith(PropertiesConverter.FLINK_PROPERTY_PREFIX)) { + flinkConfigKey = key.substring(PropertiesConverter.FLINK_PROPERTY_PREFIX.length()); + } + flinkCatalogProperties.put( + PaimonPropertiesUtils.GRAVITINO_CONFIG_TO_PAIMON.getOrDefault( + flinkConfigKey, flinkConfigKey), + value); + }); Review Comment: instead of using `GRAVITINO_CONFIG_TO_PAIMON` directly, could you resue `PaimonPropertiesUtils.toPaimonCatalogProperties(properties)` to get paimon keys? ########## flink-connector/flink/src/test/java/org/apache/gravitino/flink/connector/integration/test/FlinkCommonIT.java: ########## @@ -76,32 +95,20 @@ public void testCreateSchema() { } @Test + @EnabledIf("supportSchemaOperation") public void testGetSchema() { Review Comment: rename to `testGetSchemaWithoutCommentAndOption`? and could you place `testGetSchemaWithCommentAndOptions` after this test? ########## flink-connector/flink/build.gradle.kts: ########## @@ -170,6 +174,7 @@ tasks.test { } else { dependsOn(tasks.jar) dependsOn(":catalogs:catalog-hive:jar") + dependsOn(":catalogs:catalog-lakehouse-paimon:jar") Review Comment: not used any more? -- 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]
