JingsongLi commented on code in PR #158:
URL: https://github.com/apache/flink-table-store/pull/158#discussion_r897856853
##########
flink-table-store-hive/src/main/java/org/apache/flink/table/store/hive/HiveSchema.java:
##########
@@ -18,50 +18,67 @@
package org.apache.flink.table.store.hive;
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.table.store.file.FileStoreOptions;
+import org.apache.flink.table.store.file.schema.Schema;
+import org.apache.flink.table.store.file.schema.SchemaManager;
+import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.util.Preconditions;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.SerDeUtils;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.Properties;
+import java.util.stream.Collectors;
/** Column names, types and comments of a Hive table. */
public class HiveSchema {
- private final List<String> fieldNames;
- private final List<TypeInfo> fieldTypeInfos;
+ private static final String TBLPROPERTIES_PREFIX = "table-store.";
+ private static final String TBLPROPERTIES_PRIMARY_KEYS =
TBLPROPERTIES_PREFIX + "primary-keys";
Review Comment:
`TBLPROPERTIES_PRIMARY_KEYS` is for what? Nobody read it.
##########
flink-table-store-hive/src/main/java/org/apache/flink/table/store/TableStoreJobConf.java:
##########
@@ -87,39 +77,15 @@ public static void configureInputJobProperties(Properties
properties, Map<String
INTERNAL_LOCATION,
properties.getProperty(hive_metastoreConstants.META_TABLE_LOCATION));
- map.put(
- INTERNAL_COLUMN_NAMES,
-
properties.getProperty(hive_metastoreConstants.META_TABLE_COLUMNS));
-
+ HiveSchema hiveSchema = HiveSchema.extract(properties);
+ map.put(INTERNAL_COLUMN_NAMES, String.join(INTERNAL_SEPARATOR,
hiveSchema.fieldNames()));
List<String> serializedLogicalTypes =
- TypeInfoUtils.getTypeInfosFromTypeString(
- properties.getProperty(
-
hive_metastoreConstants.META_TABLE_COLUMN_TYPES))
- .stream()
- .map(
- t ->
- HiveTypeUtils.typeInfoToDataType(t)
- .getLogicalType()
- .asSerializableString())
+ hiveSchema.fieldTypes().stream()
+ .map(LogicalType::asSerializableString)
.collect(Collectors.toList());
- map.put(INTERNAL_COLUMN_TYPES, String.join(COLUMN_TYPES_SEPARATOR,
serializedLogicalTypes));
-
- if
(properties.containsKey(hive_metastoreConstants.META_TABLE_PARTITION_COLUMNS)) {
- map.put(
- INTERNAL_PARTITION_COLUMN_NAMES,
-
properties.getProperty(hive_metastoreConstants.META_TABLE_PARTITION_COLUMNS));
- }
-
- if (properties.containsKey(TBLPROPERTIES_PRIMARY_KEYS)) {
- map.put(INTERNAL_PRIMARY_KEYS,
properties.getProperty(TBLPROPERTIES_PRIMARY_KEYS));
- }
-
- for (ConfigOption<?> option : FileStoreOptions.allOptions()) {
- if (properties.containsKey(TBLPROPERTIES_PREFIX + option.key())) {
- map.put(
- INTERNAL_TBLPROPERTIES_PREFIX + option.key(),
- properties.getProperty(TBLPROPERTIES_PREFIX +
option.key()));
- }
+ map.put(INTERNAL_COLUMN_TYPES, String.join(INTERNAL_SEPARATOR,
serializedLogicalTypes));
Review Comment:
Can we just use a schema json?
##########
flink-table-store-hive/src/main/java/org/apache/flink/table/store/hive/HiveSchema.java:
##########
@@ -73,11 +90,134 @@ public static HiveSchema extract(Properties properties) {
String columnTypes =
properties.getProperty(serdeConstants.LIST_COLUMN_TYPES);
List<TypeInfo> typeInfos =
TypeInfoUtils.getTypeInfosFromTypeString(columnTypes);
+ List<String> partitionKeys = new ArrayList<>();
+ if
(properties.containsKey(hive_metastoreConstants.META_TABLE_PARTITION_COLUMNS)) {
Review Comment:
I am thinking why we need to check it.
Can we just assert that there is no partition and column definition?
--
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]