Class ViewUtils


  • public class ViewUtils
    extends java.lang.Object
    Utility methods for operating on common views.
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void doCommit​(java.lang.String operation, java.util.Map<java.lang.String,​java.lang.String> properties, int versionId, int parentId, ViewDefinition definition, java.lang.String location, ViewOperations ops, ViewVersionMetadata prevViewVersionMetadata)
      The method prepares the arguments to perform the commit and then proceeds to commit.
      static java.util.Map<java.lang.String,​java.lang.String> getMetacatProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      The method returns the properties to be recorded as table properties by metacat.
      static java.util.Map<java.lang.String,​java.lang.String> getSummaryProperties​(java.lang.String operation, java.util.Map<java.lang.String,​java.lang.String> properties, java.util.Map<java.lang.String,​java.lang.String> prevProperties)
      Method picks and returns the 'summary' properties from the map of table properties.
      static java.util.Map<java.lang.String,​java.lang.String> getViewVersionMetadataProperties​(java.util.Map<java.lang.String,​java.lang.String> properties, java.util.Map<java.lang.String,​java.lang.String> prevProperties, java.util.Map<java.lang.String,​java.lang.String> summaryProperties, java.util.Map<java.lang.String,​java.lang.String> metacatProperties)
      Method picks and returns common view specific properties from the map of table properties.
      static ViewDefinition retainColumnComments​(ViewDefinition newDef, ViewDefinition oldDef)
      The method ensures that when a view is getting REPLACEd and a new column comment has not been specified (indicated by 'doc' field being null), column comment from the previous version of the view is retained.
      static org.apache.iceberg.catalog.TableIdentifier toCatalogTableIdentifier​(java.lang.String tableIdentifier)  
      static void validateTableIdentifier​(org.apache.iceberg.catalog.TableIdentifier viewIdentifier)  
      • Methods inherited from class java.lang.Object

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

      • ViewUtils

        public ViewUtils()
    • Method Detail

      • getSummaryProperties

        public static java.util.Map<java.lang.String,​java.lang.String> getSummaryProperties​(java.lang.String operation,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> properties,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> prevProperties)
        Method picks and returns the 'summary' properties from the map of table properties. Summary properties are recorded in the 'sumnmary' portion of 'Version' in metadata json file.
        Parameters:
        operation - The view operation that results in alteration of the view
        properties - Map of all table properties
        prevProperties - Properties previously set
        Returns:
        A map of summary properties to be recorded in the metadata json file. These are all previously set properties overlayed with the new properties.
      • getMetacatProperties

        public static java.util.Map<java.lang.String,​java.lang.String> getMetacatProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
        The method returns the properties to be recorded as table properties by metacat.
        Parameters:
        properties - Map of all table properties
        Returns:
        Map of properties to be recorded as table properties by metacat Metacat applies these properties as an update in case the properties already exist e.g. in case of a 'replace view'
      • getViewVersionMetadataProperties

        public static java.util.Map<java.lang.String,​java.lang.String> getViewVersionMetadataProperties​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                                                                                              java.util.Map<java.lang.String,​java.lang.String> prevProperties,
                                                                                                              java.util.Map<java.lang.String,​java.lang.String> summaryProperties,
                                                                                                              java.util.Map<java.lang.String,​java.lang.String> metacatProperties)
        Method picks and returns common view specific properties from the map of table properties. These properties are recorded in the 'properties' section of the view version metadata file. Any properties that were previously set and are not being overridden are persisted.
        Parameters:
        properties - Map of all table properties
        prevProperties - Properties that were previously set
        summaryProperties - 'sumnmary' portion of 'Version' in metadata json file.
        metacatProperties - properties to be recorded as table properties by metacat
        Returns:
        A map of properties to be recorded in the metadata json file.
      • doCommit

        public static void doCommit​(java.lang.String operation,
                                    java.util.Map<java.lang.String,​java.lang.String> properties,
                                    int versionId,
                                    int parentId,
                                    ViewDefinition definition,
                                    java.lang.String location,
                                    ViewOperations ops,
                                    ViewVersionMetadata prevViewVersionMetadata)
        The method prepares the arguments to perform the commit and then proceeds to commit.
        Parameters:
        operation - View operation causing the commit
        properties - Table attributes and properties sent by the engine
        versionId - Current version id.
        parentId - Version id of the parent version.
        definition - View definition
        location - Location of view metadata
        ops - View operations object needed to perform the commit
        prevViewVersionMetadata - Previous view version metadata
      • retainColumnComments

        public static ViewDefinition retainColumnComments​(ViewDefinition newDef,
                                                          ViewDefinition oldDef)
        The method ensures that when a view is getting REPLACEd and a new column comment has not been specified (indicated by 'doc' field being null), column comment from the previous version of the view is retained.
        Parameters:
        newDef - new view definition, definition specified by REPLACE
        oldDef - current view definition
        Returns:
        new view definition enhanced with column comments from current view definition where applicable.
      • validateTableIdentifier

        public static void validateTableIdentifier​(org.apache.iceberg.catalog.TableIdentifier viewIdentifier)
      • toCatalogTableIdentifier

        public static org.apache.iceberg.catalog.TableIdentifier toCatalogTableIdentifier​(java.lang.String tableIdentifier)