rdsr commented on a change in pull request #1842:
URL: https://github.com/apache/iceberg/pull/1842#discussion_r533600886



##########
File path: 
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTypeConverter.java
##########
@@ -30,7 +37,52 @@ private HiveTypeConverter() {
 
   }
 
-  public static String convert(Type type) {
+  /**
+   * Converts the Iceberg schema to a Hive schema.
+   * @param schema The original Iceberg schema to convert
+   * @return The Hive column list generated from the Iceberg schema
+   */
+  public static List<FieldSchema> hiveSchema(Schema schema) {
+    return schema.columns().stream()
+        .map(col -> new FieldSchema(col.name(), 
HiveTypeConverter.convert(col.type()), ""))
+        .collect(Collectors.toList());
+  }
+
+  /**
+   * Converts the list of Hive FieldSchemas to an Iceberg schema.
+   * <p>
+   * The list should contain the columns and the partition columns as well.
+   * @param fieldSchemas The list of the columns
+   * @return An equivalent Iceberg Schema
+   */
+  public static Schema icebergSchema(List<FieldSchema> fieldSchemas) {
+    List<String> names = new ArrayList<>(fieldSchemas.size());
+    List<TypeInfo> typeInfos = new ArrayList<>(fieldSchemas.size());
+
+    for (FieldSchema col : fieldSchemas) {
+      names.add(col.getName());
+      typeInfos.add(TypeInfoUtils.getTypeInfoFromTypeString(col.getType()));

Review comment:
       Handling is separately is fine!




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to