You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/12/13 19:25:03 UTC

[GitHub] [flink] xuefuz commented on a change in pull request #10566: [FLINK-15234][hive] hive table created from flink catalog table cannot have null properties in parameters

xuefuz commented on a change in pull request #10566: [FLINK-15234][hive] hive table created from flink catalog table cannot have null properties in parameters
URL: https://github.com/apache/flink/pull/10566#discussion_r357791645
 
 

 ##########
 File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
 ##########
 @@ -559,24 +562,34 @@ private CatalogBaseTable instantiateCatalogTable(Table hiveTable, HiveConf hiveC
 		}
 	}
 
-	private  static Table instantiateHiveTable(ObjectPath tablePath, CatalogBaseTable table) {
+	@VisibleForTesting
+	protected static Table instantiateHiveTable(ObjectPath tablePath, CatalogBaseTable table) {
 		// let Hive set default parameters for us, e.g. serialization.format
 		Table hiveTable = org.apache.hadoop.hive.ql.metadata.Table.getEmptyTable(tablePath.getDatabaseName(),
 			tablePath.getObjectName());
 		hiveTable.setCreateTime((int) (System.currentTimeMillis() / 1000));
 
 		Map<String, String> properties = new HashMap<>(table.getProperties());
 		// Table comment
-		properties.put(HiveCatalogConfig.COMMENT, table.getComment());
-
-		boolean isGeneric = Boolean.valueOf(properties.get(CatalogConfig.IS_GENERIC));
+		if (table.getComment() != null) {
+			properties.put(HiveCatalogConfig.COMMENT, table.getComment());
+		}
 
-		if (isGeneric) {
+		// When creating a table, A hive table needs explicitly have a key is_generic = false
+		// otherwise, this is a generic table if 1) the key is missing 2) is_generic = true
+		// this is opposite to reading a table and instantiating a CatalogTable. See instantiateCatalogTable()
+		String key = properties.get(CatalogConfig.IS_GENERIC);
+		if (key == null || Boolean.valueOf(key)) {
 			properties = maskFlinkProperties(properties);
+			properties.put(CatalogConfig.IS_GENERIC, String.valueOf(true));
 		}
+
 
 Review comment:
   Name "key" might be misleading, as it actually is the value of a potential key. "isGeneric" seems to be a better name.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services