nastra commented on a change in pull request #3308:
URL: https://github.com/apache/iceberg/pull/3308#discussion_r732027328



##########
File path: 
flink/src/test/java/org/apache/iceberg/flink/TestFlinkCatalogFactory.java
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.iceberg.flink;
+
+import java.util.Map;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.hive.HiveCatalog;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFlinkCatalogFactory {
+
+  private Map<String, String> props;
+
+  @Before
+  public void before() {
+    props = Maps.newHashMap();
+    props.put("type", "iceberg");
+    props.put(CatalogProperties.WAREHOUSE_LOCATION, "/tmp/location");
+  }
+
+  @Test
+  public void testCreateCreateCatalogHive() {
+    String catalogName = "hiveCatalog";
+    props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, 
FlinkCatalogFactory.ICEBERG_CATALOG_TYPE_HIVE);
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(HiveCatalog.class);
+  }
+
+  @Test
+  public void testCreateCreateCatalogHadoop() {
+    String catalogName = "hadoopCatalog";
+    props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, 
FlinkCatalogFactory.ICEBERG_CATALOG_TYPE_HADOOP);
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(HadoopCatalog.class);

Review comment:
       nit: you can combine both assert checks: 
`Assertions.assertThat(catalog).isNotNull().isInstanceOf(HadoopCatalog.class)`

##########
File path: site/docs/flink.md
##########
@@ -190,9 +190,30 @@ For more details, please refer to the [Python Table 
API](https://ci.apache.org/p
 
 Flink 1.11 support to create catalogs by using flink sql.
 
+### Catalog Configuration
+
+A catalog is created and named by executing the following query (replace 
`<catalog_name>` with your catalog name and
+`<config_key>`=`<config_value>` with catalog implementation config):   
+
+```sql
+CREATE CATALOG <catalog_name> WITH (
+  'type'='iceberg',
+  `<config_key>`=`<config_value>`
+); 
+```
+
+The following properties can be set globally and not limited to specific 
catalog implementation:  

Review comment:
       nit: `The following properties can be set globally and are not limited 
to a specific catalog implementation`

##########
File path: 
flink/src/test/java/org/apache/iceberg/flink/TestFlinkCatalogFactory.java
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.iceberg.flink;
+
+import java.util.Map;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.hive.HiveCatalog;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFlinkCatalogFactory {
+
+  private Map<String, String> props;
+
+  @Before
+  public void before() {
+    props = Maps.newHashMap();
+    props.put("type", "iceberg");
+    props.put(CatalogProperties.WAREHOUSE_LOCATION, "/tmp/location");
+  }
+
+  @Test
+  public void testCreateCreateCatalogHive() {
+    String catalogName = "hiveCatalog";
+    props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, 
FlinkCatalogFactory.ICEBERG_CATALOG_TYPE_HIVE);
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(HiveCatalog.class);
+  }
+
+  @Test
+  public void testCreateCreateCatalogHadoop() {
+    String catalogName = "hadoopCatalog";
+    props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, 
FlinkCatalogFactory.ICEBERG_CATALOG_TYPE_HADOOP);
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(HadoopCatalog.class);
+  }
+
+  @Test
+  public void testCreateCreateCatalogCustom() {
+    String catalogName = "customCatalog";
+    props.put(CatalogProperties.CATALOG_IMPL, 
CustomHadoopCatalog.class.getName());
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(CustomHadoopCatalog.class);

Review comment:
       nit: you can combine both assert checks: 
`Assertions.assertThat(catalog).isNotNull().isInstanceOf(CustomHadoopCatalog.class)`

##########
File path: 
flink/src/test/java/org/apache/iceberg/flink/TestFlinkCatalogFactory.java
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.iceberg.flink;
+
+import java.util.Map;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.AssertHelpers;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.hive.HiveCatalog;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFlinkCatalogFactory {
+
+  private Map<String, String> props;
+
+  @Before
+  public void before() {
+    props = Maps.newHashMap();
+    props.put("type", "iceberg");
+    props.put(CatalogProperties.WAREHOUSE_LOCATION, "/tmp/location");
+  }
+
+  @Test
+  public void testCreateCreateCatalogHive() {
+    String catalogName = "hiveCatalog";
+    props.put(FlinkCatalogFactory.ICEBERG_CATALOG_TYPE, 
FlinkCatalogFactory.ICEBERG_CATALOG_TYPE_HIVE);
+
+    Catalog catalog = FlinkCatalogFactory
+        .createCatalogLoader(catalogName, props, new Configuration())
+        .loadCatalog();
+
+    Assert.assertNotNull(catalog);
+    Assertions.assertThat(catalog).isInstanceOf(HiveCatalog.class);

Review comment:
       nit: you can combine both assert checks: 
`Assertions.assertThat(catalog).isNotNull().isInstanceOf(HiveCatalog.class)`

##########
File path: site/docs/flink.md
##########
@@ -190,9 +190,30 @@ For more details, please refer to the [Python Table 
API](https://ci.apache.org/p
 
 Flink 1.11 support to create catalogs by using flink sql.
 
+### Catalog Configuration
+
+A catalog is created and named by executing the following query (replace 
`<catalog_name>` with your catalog name and
+`<config_key>`=`<config_value>` with catalog implementation config):   
+
+```sql
+CREATE CATALOG <catalog_name> WITH (
+  'type'='iceberg',
+  `<config_key>`=`<config_value>`
+); 
+```
+
+The following properties can be set globally and not limited to specific 
catalog implementation:  
+
+* `type`: Please just use `iceberg` for iceberg table format. (Required)
+* `catalog-type`: Iceberg currently support `hive` or `hadoop` catalog types, 
as well as custom catalogs. When using a custom catalog, this should be left 
unset. (Required)
+* `catalog-impl`: The custom catalog implementation, must not be unset if 
`catalog-type` is unset. (Optional)

Review comment:
       double negation in `must not be unset if `catalog-type` is unset` is 
rather confusing. Maybe that's something that can be improved?

##########
File path: site/docs/flink.md
##########
@@ -190,9 +190,30 @@ For more details, please refer to the [Python Table 
API](https://ci.apache.org/p
 
 Flink 1.11 support to create catalogs by using flink sql.
 
+### Catalog Configuration
+
+A catalog is created and named by executing the following query (replace 
`<catalog_name>` with your catalog name and
+`<config_key>`=`<config_value>` with catalog implementation config):   
+
+```sql
+CREATE CATALOG <catalog_name> WITH (
+  'type'='iceberg',
+  `<config_key>`=`<config_value>`
+); 
+```
+
+The following properties can be set globally and not limited to specific 
catalog implementation:  
+
+* `type`: Please just use `iceberg` for iceberg table format. (Required)
+* `catalog-type`: Iceberg currently support `hive` or `hadoop` catalog types, 
as well as custom catalogs. When using a custom catalog, this should be left 
unset. (Required)
+* `catalog-impl`: The custom catalog implementation, must not be unset if 
`catalog-type` is unset. (Optional)
+* `property-version`: Version number to describe the property version. This 
property can be used for backwards compatibility in case the property format 
changes. The current property version is `1`. (Optional)
+* `cache-enabled`: Whether to enable catalog cache, default value is `true`
+* 

Review comment:
       `*` needs to be removed




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to