You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by bl...@apache.org on 2019/05/15 23:56:14 UTC
[flink] branch master updated: [FLINK-12511][table][hive] make
variable 'comment' in all catalog metadata classes final
This is an automated email from the ASF dual-hosted git repository.
bli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new 2b2c064 [FLINK-12511][table][hive] make variable 'comment' in all catalog metadata classes final
2b2c064 is described below
commit 2b2c0641c107afa4f3e35908e64368fa95e61fc9
Author: bowen.li <bo...@gmail.com>
AuthorDate: Wed May 15 13:13:23 2019 -0700
[FLINK-12511][table][hive] make variable 'comment' in all catalog metadata classes final
This PR removes the default value of "comment" and make it final that can only be assigned value upon construction, and ends the not-so-well-designed overloaded constructors for catalog metadata classes.
This closes #8457.
---
.../table/catalog/hive/HiveCatalogDatabase.java | 22 +++----------
.../flink/table/catalog/hive/HiveCatalogTable.java | 2 +-
.../flink/table/catalog/hive/HiveCatalogView.java | 2 +-
.../table/catalog/GenericCatalogDatabase.java | 12 +++----
.../flink/table/catalog/GenericCatalogTable.java | 2 +-
.../flink/table/catalog/GenericCatalogView.java | 37 ++++++++++++++--------
6 files changed, 35 insertions(+), 42 deletions(-)
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogDatabase.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogDatabase.java
index a7cf5c2..45a6271 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogDatabase.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogDatabase.java
@@ -19,13 +19,11 @@
package org.apache.flink.table.catalog.hive;
import org.apache.flink.table.catalog.CatalogDatabase;
-import org.apache.flink.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import static org.apache.flink.util.Preconditions.checkArgument;
import static org.apache.flink.util.Preconditions.checkNotNull;
/**
@@ -35,28 +33,18 @@ public class HiveCatalogDatabase implements CatalogDatabase {
// Property of the database
private final Map<String, String> properties;
// HDFS path of the database
- private String location;
+ private final String location;
// Comment of the database
- private String comment = "This is a hive catalog database.";
-
- public HiveCatalogDatabase() {
- properties = new HashMap<>();
- }
-
- public HiveCatalogDatabase(Map<String, String> properties) {
- this.properties = checkNotNull(properties, "properties cannot be null");
- }
+ private final String comment;
public HiveCatalogDatabase(Map<String, String> properties, String comment) {
- this(properties);
- this.comment = checkNotNull(comment, "comment cannot be null");
+ this(properties, null, comment);
}
public HiveCatalogDatabase(Map<String, String> properties, String location, String comment) {
- this(properties, comment);
-
- checkArgument(!StringUtils.isNullOrWhitespaceOnly(location), "location cannot be null or empty");
+ this.properties = checkNotNull(properties, "properties cannot be null");
this.location = location;
+ this.comment = checkNotNull(comment, "comment cannot be null");
}
@Override
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogTable.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogTable.java
index 87fb413..5a2fbff 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogTable.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogTable.java
@@ -41,7 +41,7 @@ public class HiveCatalogTable implements CatalogTable {
// Properties of the table
private final Map<String, String> properties;
// Comment of the table
- private String comment = "This is a hive catalog table.";
+ private final String comment;
public HiveCatalogTable(
TableSchema tableSchema,
diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogView.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogView.java
index 968bfd8..9930709 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogView.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogView.java
@@ -48,7 +48,7 @@ public class HiveCatalogView implements CatalogView {
// Properties of the view
private final Map<String, String> properties;
// Comment of the view
- private String comment = "This is a hive catalog view.";
+ private final String comment;
public HiveCatalogView(
String originalQuery,
diff --git a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogDatabase.java b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogDatabase.java
index d5df274..dd2b1f0 100644
--- a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogDatabase.java
+++ b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogDatabase.java
@@ -29,19 +29,15 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
*/
public class GenericCatalogDatabase implements CatalogDatabase {
private final Map<String, String> properties;
- private String comment = "This is a generic catalog database.";
-
- public GenericCatalogDatabase() {
- this.properties = new HashMap<>();
- }
+ private final String comment;
public GenericCatalogDatabase(Map<String, String> properties) {
- this.properties = checkNotNull(properties, "properties cannot be null");
+ this(properties, null);
}
public GenericCatalogDatabase(Map<String, String> properties, String comment) {
- this(properties);
- this.comment = checkNotNull(comment, "comment cannot be null");
+ this.properties = checkNotNull(properties, "properties cannot be null");
+ this.comment = comment;
}
@Override
diff --git a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
index 56d8377..eff8305 100644
--- a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
+++ b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
@@ -39,7 +39,7 @@ public class GenericCatalogTable implements CatalogTable {
// Properties of the table
private final Map<String, String> properties;
// Comment of the table
- private String comment = "This is a generic catalog table.";
+ private final String comment;
public GenericCatalogTable(
TableSchema tableSchema,
diff --git a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogView.java b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogView.java
index 4249644..2a8a184 100644
--- a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogView.java
+++ b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogView.java
@@ -19,11 +19,15 @@
package org.apache.flink.table.catalog;
import org.apache.flink.table.api.TableSchema;
+import org.apache.flink.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
/**
* A generic catalog view implementation.
*/
@@ -37,22 +41,27 @@ public class GenericCatalogView implements CatalogView {
// Expanded query text takes care of the this, as an example.
private final String expandedQuery;
- private final TableSchema schema;
+ // Schema of the view (column names and types)
+ private final TableSchema tableSchema;
+ // Properties of the view
private final Map<String, String> properties;
- private String comment = "This is a generic catalog view";
+ // Comment of the view
+ private final String comment;
+
+ public GenericCatalogView(
+ String originalQuery,
+ String expandedQuery,
+ TableSchema tableSchema,
+ Map<String, String> properties,
+ String comment) {
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(originalQuery), "original query cannot be null or empty");
+ checkArgument(!StringUtils.isNullOrWhitespaceOnly(expandedQuery), "expanded query cannot be null or empty");
- public GenericCatalogView(String originalQuery, String expandedQuery, TableSchema schema,
- Map<String, String> properties, String comment) {
- this(originalQuery, expandedQuery, schema, properties);
- this.comment = comment;
- }
-
- public GenericCatalogView(String originalQuery, String expandedQuery, TableSchema schema,
- Map<String, String> properties) {
this.originalQuery = originalQuery;
this.expandedQuery = expandedQuery;
- this.schema = schema;
- this.properties = properties;
+ this.tableSchema = checkNotNull(tableSchema, "tableSchema cannot be null");
+ this.properties = checkNotNull(properties, "properties cannot be null");
+ this.comment = comment;
}
@Override
@@ -72,7 +81,7 @@ public class GenericCatalogView implements CatalogView {
@Override
public TableSchema getSchema() {
- return schema;
+ return tableSchema;
}
@Override
@@ -82,7 +91,7 @@ public class GenericCatalogView implements CatalogView {
@Override
public GenericCatalogView copy() {
- return new GenericCatalogView(this.originalQuery, this.expandedQuery, schema.copy(),
+ return new GenericCatalogView(this.originalQuery, this.expandedQuery, tableSchema.copy(),
new HashMap<>(this.properties), comment);
}