Class CatalogUtil


  • public class CatalogUtil
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Catalog buildIcebergCatalog​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.String> options, org.apache.hadoop.conf.Configuration conf)
      Build an Iceberg Catalog based on a map of catalog properties and optional Hadoop configuration.
      static void dropTableData​(FileIO io, TableMetadata metadata)
      Drops all data and metadata files referenced by TableMetadata.
      static Catalog loadCatalog​(java.lang.String impl, java.lang.String catalogName, java.util.Map<java.lang.String,​java.lang.String> properties, org.apache.hadoop.conf.Configuration hadoopConf)
      Load a custom catalog implementation.
      static FileIO loadFileIO​(java.lang.String impl, java.util.Map<java.lang.String,​java.lang.String> properties, org.apache.hadoop.conf.Configuration hadoopConf)
      Load a custom FileIO implementation.
      • Methods inherited from class java.lang.Object

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

      • ICEBERG_CATALOG_TYPE

        public static final java.lang.String ICEBERG_CATALOG_TYPE
        Shortcut catalog property to load a catalog implementation through a short type name, instead of specifying a full java class through CatalogProperties.CATALOG_IMPL. Currently the following type to implementation mappings are supported:
        • hive: org.apache.iceberg.hive.HiveCatalog
        • hadoop: org.apache.iceberg.hadoop.HadoopCatalog
        See Also:
        Constant Field Values
      • ICEBERG_CATALOG_TYPE_HADOOP

        public static final java.lang.String ICEBERG_CATALOG_TYPE_HADOOP
        See Also:
        Constant Field Values
      • ICEBERG_CATALOG_TYPE_HIVE

        public static final java.lang.String ICEBERG_CATALOG_TYPE_HIVE
        See Also:
        Constant Field Values
      • ICEBERG_CATALOG_HIVE

        public static final java.lang.String ICEBERG_CATALOG_HIVE
        See Also:
        Constant Field Values
      • ICEBERG_CATALOG_HADOOP

        public static final java.lang.String ICEBERG_CATALOG_HADOOP
        See Also:
        Constant Field Values
    • Method Detail

      • dropTableData

        public static void dropTableData​(FileIO io,
                                         TableMetadata metadata)
        Drops all data and metadata files referenced by TableMetadata.

        This should be called by dropTable implementations to clean up table files once the table has been dropped in the metastore.

        Parameters:
        io - a FileIO to use for deletes
        metadata - the last valid TableMetadata instance for a dropped table.
      • loadCatalog

        public static Catalog loadCatalog​(java.lang.String impl,
                                          java.lang.String catalogName,
                                          java.util.Map<java.lang.String,​java.lang.String> properties,
                                          org.apache.hadoop.conf.Configuration hadoopConf)
        Load a custom catalog implementation.

        The catalog must have a no-arg constructor. If the class implements Configurable, a Hadoop config will be passed using Configurable.setConf(Configuration). Catalog.initialize(String catalogName, Map options) is called to complete the initialization.

        Parameters:
        impl - catalog implementation full class name
        catalogName - catalog name
        properties - catalog properties
        hadoopConf - hadoop configuration if needed
        Returns:
        initialized catalog object
        Throws:
        java.lang.IllegalArgumentException - if no-arg constructor not found or error during initialization
      • buildIcebergCatalog

        public static Catalog buildIcebergCatalog​(java.lang.String name,
                                                  java.util.Map<java.lang.String,​java.lang.String> options,
                                                  org.apache.hadoop.conf.Configuration conf)
        Build an Iceberg Catalog based on a map of catalog properties and optional Hadoop configuration.

        This method examines both the ICEBERG_CATALOG_TYPE and CatalogProperties.CATALOG_IMPL properties to determine the catalog implementation to load. If nothing is specified for both properties, Hive catalog will be loaded by default.

        Parameters:
        name - catalog name
        options - catalog properties
        conf - Hadoop configuration
        Returns:
        initialized catalog
      • loadFileIO

        public static FileIO loadFileIO​(java.lang.String impl,
                                        java.util.Map<java.lang.String,​java.lang.String> properties,
                                        org.apache.hadoop.conf.Configuration hadoopConf)
        Load a custom FileIO implementation.

        The implementation must have a no-arg constructor. If the class implements Configurable, a Hadoop config will be passed using Configurable.setConf(Configuration). FileIO.initialize(Map properties) is called to complete the initialization.

        Parameters:
        impl - full class name of a custom FileIO implementation
        hadoopConf - hadoop configuration
        Returns:
        FileIO class
        Throws:
        java.lang.IllegalArgumentException - if class path not found or right constructor not found or the loaded class cannot be casted to the given interface type