lirui-apache commented on a change in pull request #11012: [FLINK-15858][hive] 
Store generic table schema as properties
URL: https://github.com/apache/flink/pull/11012#discussion_r374545696
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
 ##########
 @@ -587,57 +599,67 @@ protected static Table instantiateHiveTable(ObjectPath 
tablePath, CatalogBaseTab
                // 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()
+               boolean isGeneric;
                if (!properties.containsKey(CatalogConfig.IS_GENERIC)) {
-                       // must be a generic catalog
+                       // must be a generic table
+                       isGeneric = true;
                        properties.put(CatalogConfig.IS_GENERIC, 
String.valueOf(true));
-                       properties = maskFlinkProperties(properties);
                } else {
-                       boolean isGeneric = 
Boolean.valueOf(properties.get(CatalogConfig.IS_GENERIC));
-
-                       if (isGeneric) {
-                               properties = maskFlinkProperties(properties);
-                       }
+                       isGeneric = 
Boolean.parseBoolean(properties.get(CatalogConfig.IS_GENERIC));
                }
 
-               // Table properties
-               hiveTable.setParameters(properties);
-
                // Hive table's StorageDescriptor
                StorageDescriptor sd = hiveTable.getSd();
                setStorageFormat(sd, properties);
 
-               List<FieldSchema> allColumns = 
HiveTableUtil.createHiveColumns(table.getSchema());
-
-               // Table columns and partition keys
-               if (table instanceof CatalogTableImpl) {
-                       CatalogTable catalogTable = (CatalogTableImpl) table;
-
-                       if (catalogTable.isPartitioned()) {
-                               int partitionKeySize = 
catalogTable.getPartitionKeys().size();
-                               List<FieldSchema> regularColumns = 
allColumns.subList(0, allColumns.size() - partitionKeySize);
-                               List<FieldSchema> partitionColumns = 
allColumns.subList(allColumns.size() - partitionKeySize, allColumns.size());
+               if (isGeneric) {
+                       DescriptorProperties tableSchemaProps = new 
DescriptorProperties(true);
+                       
tableSchemaProps.putTableSchema(HiveCatalogConfig.GENERIC_TABLE_SCHEMA_PREFIX, 
table.getSchema());
+                       properties.putAll(tableSchemaProps.asMap());
+
+                       if (table instanceof CatalogTableImpl) {
+                               List<String> partColNames = ((CatalogTableImpl) 
table).getPartitionKeys();
+                               if (!partColNames.isEmpty()) {
+                                       
properties.put(HiveCatalogConfig.GENERIC_PART_COL_NAMES, String.join(",", 
partColNames));
 
 Review comment:
   OK I'll create another JIRA to track that.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to