zjuwangg commented on a change in pull request #8522:
[FLINK-12572][hive]Implement HiveInputFormat to read Hive tables
URL: https://github.com/apache/flink/pull/8522#discussion_r289590766
##########
File path:
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/util/HiveTableUtil.java
##########
@@ -71,4 +80,37 @@ public static TableSchema
createTableSchema(List<FieldSchema> cols, List<FieldSc
return columns;
}
+
+ //
--------------------------------------------------------------------------------------------
+ // Helper methods
+ //
--------------------------------------------------------------------------------------------
+
+ /**
+ * Create properties info to initialize a SerDe.
+ * @param storageDescriptor
+ * @return
+ */
+ public static Properties
createPropertiesFromStorageDescriptor(StorageDescriptor storageDescriptor) {
+ SerDeInfo serDeInfo = storageDescriptor.getSerdeInfo();
+ Map<String, String> parameters = serDeInfo.getParameters();
+ Properties properties = new Properties();
+ properties.setProperty(
+ serdeConstants.SERIALIZATION_FORMAT,
+
parameters.get(serdeConstants.SERIALIZATION_FORMAT));
+ List<String> colTypes = new ArrayList<>();
+ List<String> colNames = new ArrayList<>();
+ List<FieldSchema> cols = storageDescriptor.getCols();
+ for (FieldSchema col: cols){
+ colTypes.add(col.getType());
+ colNames.add(col.getName());
+ }
+ properties.setProperty(serdeConstants.LIST_COLUMNS,
StringUtils.join(colNames, ","));
+ // Note: serdeConstants.COLUMN_NAME_DELIMITER is not defined in
previous Hive. We use a literal to save on shim
+ properties.setProperty("column.name.delimite",
String.valueOf(SerDeUtils.COMMA));
+ properties.setProperty(serdeConstants.LIST_COLUMN_TYPES,
StringUtils.join(colTypes, DEFAULT_LIST_COLUMN_TYPES_SEPARATOR));
Review comment:
in line 107, it is a hive inner design. Hive use ':'/','/';' as columnType
delimiter.
----------------------------------------------------------------
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