Package org.apache.iceberg.viewdepoc
Class ViewUtils
- java.lang.Object
-
- org.apache.iceberg.viewdepoc.ViewUtils
-
public class ViewUtils extends java.lang.ObjectUtility 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 voiddoCommit(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 ViewDefinitionretainColumnComments(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.TableIdentifiertoCatalogTableIdentifier(java.lang.String tableIdentifier)static voidvalidateTableIdentifier(org.apache.iceberg.catalog.TableIdentifier viewIdentifier)
-
-
-
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 viewproperties- Map of all table propertiesprevProperties- 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 propertiesprevProperties- Properties that were previously setsummaryProperties- '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 commitproperties- Table attributes and properties sent by the engineversionId- Current version id.parentId- Version id of the parent version.definition- View definitionlocation- Location of view metadataops- View operations object needed to perform the commitprevViewVersionMetadata- 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 REPLACEoldDef- 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)
-
-