Class ViewUtils

java.lang.Object
org.apache.iceberg.viewdepoc.ViewUtils

public class ViewUtils extends Object
Utility methods for operating on common views.
  • Constructor Details

    • ViewUtils

      public ViewUtils()
  • Method Details

    • getSummaryProperties

      public static Map<String,String> getSummaryProperties(String operation, Map<String,String> properties, Map<String,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 Map<String,String> getMetacatProperties(Map<String,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 Map<String,String> getViewVersionMetadataProperties(Map<String,String> properties, Map<String,String> prevProperties, Map<String,String> summaryProperties, Map<String,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(String operation, Map<String,String> properties, int versionId, int parentId, ViewDefinition definition, 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(String tableIdentifier)