Class HiveSchemaUtil


  • public final class HiveSchemaUtil
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Schema convert​(java.util.List<java.lang.String> names, java.util.List<org.apache.hadoop.hive.serde2.typeinfo.TypeInfo> types, java.util.List<java.lang.String> comments)
      Converts the Hive list of column names and column types to an Iceberg schema.
      static Schema convert​(java.util.List<java.lang.String> names, java.util.List<org.apache.hadoop.hive.serde2.typeinfo.TypeInfo> types, java.util.List<java.lang.String> comments, boolean autoConvert)
      Converts the Hive list of column names and column types to an Iceberg schema.
      static Schema convert​(java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas)
      Converts a Hive schema (list of FieldSchema objects) to an Iceberg schema.
      static Schema convert​(java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas, boolean autoConvert)
      Converts a Hive schema (list of FieldSchema objects) to an Iceberg schema.
      static Type convert​(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo typeInfo)
      Converts a Hive typeInfo object to an Iceberg type.
      static java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> convert​(Schema schema)
      Converts the Iceberg schema to a Hive schema (list of FieldSchema objects).
      static org.apache.hadoop.hive.serde2.typeinfo.TypeInfo convert​(Type type)
      Converts an Iceberg type to a Hive TypeInfo object.
      static PartitionSpec spec​(Schema schema, java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas)
      Converts the Hive partition columns to Iceberg identity partition specification.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • convert

        public static java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> convert​(Schema schema)
        Converts the Iceberg schema to a Hive schema (list of FieldSchema objects).
        Parameters:
        schema - The original Iceberg schema to convert
        Returns:
        The Hive column list generated from the Iceberg schema
      • convert

        public static Schema convert​(java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas)
        Converts a Hive schema (list of FieldSchema objects) to an Iceberg schema. If some of the types are not convertible then exception is thrown.
        Parameters:
        fieldSchemas - The list of the columns
        Returns:
        An equivalent Iceberg Schema
      • convert

        public static Schema convert​(java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas,
                                     boolean autoConvert)
        Converts a Hive schema (list of FieldSchema objects) to an Iceberg schema.
        Parameters:
        fieldSchemas - The list of the columns
        autoConvert - If true then TINYINT and SMALLINT is converted to INTEGER and VARCHAR and CHAR is converted to STRING. Otherwise if these types are used in the Hive schema then exception is thrown.
        Returns:
        An equivalent Iceberg Schema
      • spec

        public static PartitionSpec spec​(Schema schema,
                                         java.util.List<org.apache.hadoop.hive.metastore.api.FieldSchema> fieldSchemas)
        Converts the Hive partition columns to Iceberg identity partition specification.
        Parameters:
        schema - The Iceberg schema
        fieldSchemas - The partition column specification
        Returns:
        The Iceberg partition specification
      • convert

        public static Schema convert​(java.util.List<java.lang.String> names,
                                     java.util.List<org.apache.hadoop.hive.serde2.typeinfo.TypeInfo> types,
                                     java.util.List<java.lang.String> comments)
        Converts the Hive list of column names and column types to an Iceberg schema. If some of the types are not convertible then exception is thrown.
        Parameters:
        names - The list of the Hive column names
        types - The list of the Hive column types
        comments - The list of the Hive column comments
        Returns:
        The Iceberg schema
      • convert

        public static Schema convert​(java.util.List<java.lang.String> names,
                                     java.util.List<org.apache.hadoop.hive.serde2.typeinfo.TypeInfo> types,
                                     java.util.List<java.lang.String> comments,
                                     boolean autoConvert)
        Converts the Hive list of column names and column types to an Iceberg schema.
        Parameters:
        names - The list of the Hive column names
        types - The list of the Hive column types
        comments - The list of the Hive column comments, can be null
        autoConvert - If true then TINYINT and SMALLINT is converted to INTEGER and VARCHAR and CHAR is converted to STRING. Otherwise if these types are used in the Hive schema then exception is thrown.
        Returns:
        The Iceberg schema
      • convert

        public static org.apache.hadoop.hive.serde2.typeinfo.TypeInfo convert​(Type type)
        Converts an Iceberg type to a Hive TypeInfo object.
        Parameters:
        type - The Iceberg type
        Returns:
        The Hive type
      • convert

        public static Type convert​(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo typeInfo)
        Converts a Hive typeInfo object to an Iceberg type.
        Parameters:
        typeInfo - The Hive type
        Returns:
        The Iceberg type