Cloudera Enterprise 5.15.x | Other versions

Metadata Policy Expressions

A metadata policy expression is a Java expression that uses Java expressions instead of string literals to define properties for a metadata extraction policy. Properties that can be defined using Java expressions include entity names and descriptions, managed metadata, key-value pairs, and JMS notification messages. Declare classes for the expression to use in the policy's import statement. The Java expressions defined to apply policies must evaluate to strings.

The Cloudera Navigator console displays an Expression check box near entities that can use Java expressions. Click the help icon for a pop-up example of an expression:



Expressions can support the following:
  • Metadata Assignments
    • Name
    • Description
    • Managed Metadata
    • Key-Value Pairs
  • JMS Notification Messages
  Note: Using Java expressions to define policies is not enabled by default. See Configuring the Server for Policy Messages to enable this feature.

Including Entity Properties in Policy Expressions

To include entity properties in property expressions, use the entity.get method and pass the property and return type as follows:
entity.get(EnumTypeProperties.PROPERTY, return_type)

For any operation based on return type (return_type), use the return type listed in Entity Property Enum Reference. Each PROPERTY listed for a given EnumType has its data type (return_type) specified following the Java comment (//).

For example, the return type for the ORIGINAL_NAME property of the FSEntityProperties class is java.lang.String, which means you can use String methods such as toLowerCase() to modify the returned value:

entity.get(FSEntityProperties.ORIGINAL_NAME, String.class).toLowerCase()
  Note: For expressions that do not require specific type, use Object.class as the return type.

Metadata Policy Expression Examples

Here are some short examples showing how to use Java expressions for metadata policies. The examples include the import statements to enter into to the Import Statements field when creating policies in the Cloudera Navigator console.

  • Set a filesystem entity name to the original name concatenated with the entity type:
    entity.get(FSEntityProperties.ORIGINAL_NAME, Object.class) + " " + entity.get(FSEntityProperties.TYPE, Object.class)
    Import Statements:
    import com.cloudera.nav.hdfs.model.FSEntityProperties;
  • Add the entity's creation date to the entity name:
    entity.get(FSEntityProperties.ORIGINAL_NAME, Object.class) + " - "
    + new SimpleDateFormat("yyyy-MM-dd").format(entity.get(FSEntityProperties.CREATED, Instant.class).toDate())
    Import Statements:
    import com.cloudera.nav.hdfs.model.FSEntityProperties; import java.text.SimpleDateFormat; import org.joda.time.Instant; 
  • Set the key-value pair: retain_util-seven years from today's local time:
    new DateTime().plusYears(7).toLocalDateTime().toString("MMM dd yyyy", Locale.US)
    Import statements:
    import org.joda.time.DateTime; import java.util.Locale;

Entity Property Enum Reference

The Java enumerations for retrieving properties from each entity type are listed below.

Continue reading:

    com.cloudera.nav.hdfs.model.FSEntityProperties
    public enum FSEntityProperties implements PropertyEnum {
      PERMISSIONS, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      SIZE, // Return type: java.lang.Long
      OWNER, // Return type: java.lang.String
      LAST_MODIFIED, // Return type: org.joda.time.Instant
      SOURCE_TYPE, // Return type: java.lang.String
      DELETED, // Return type: java.lang.Boolean
      FILE_SYSTEM_PATH, // Return type: java.lang.String
      CREATED, // Return type: org.joda.time.Instant
      LAST_ACCESSED, // Return type: org.joda.time.Instant
      GROUP, // Return type: java.lang.String
      MIME_TYPE, // Return type: java.lang.String
      DELETE_TIME, // Return type: java.lang.Long
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveColumnProperties
    public enum HiveColumnProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      DELETED, // Return type: java.lang.Boolean
      DATA_TYPE, // Return type: java.lang.String
      ORIGINAL_DESCRIPTION, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveDatabaseProperties
    public enum HiveDatabaseProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      ORIGINAL_DESCRIPTION, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      DELETED, // Return type: java.lang.Boolean
      FILE_SYSTEM_PATH, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HivePartitionProperties
    public enum HivePartitionProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      DELETED, // Return type: java.lang.Boolean
      FILE_SYSTEM_PATH, // Return type: java.lang.String
      CREATED, // Return type: org.joda.time.Instant
      LAST_ACCESSED, // Return type: org.joda.time.Instant
      COL_VALUES, // Return type: java.util.List
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveQueryExecutionProperties
    public enum HiveQueryExecutionProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      ENDED, // Return type: org.joda.time.Instant
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      STARTED, // Return type: org.joda.time.Instant
      PRINCIPAL, // Return type: java.lang.String
      WF_INST_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveQueryPartProperties
    public enum HiveQueryPartProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveQueryProperties
    public enum HiveQueryProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      QUERY_TEXT, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.hive.model.HiveTableProperties
    public enum HiveTableProperties implements PropertyEnum {
      OWNER, // Return type: java.lang.String
      INPUT_FORMAT, // Return type: java.lang.String
      OUTPUT_FORMAT, // Return type: java.lang.String
      DELETED, // Return type: java.lang.Boolean
      FILE_SYSTEM_PATH, // Return type: java.lang.String
      COMPRESSED, // Return type: java.lang.Boolean
      PARTITION_COL_NAMES, // Return type: java.util.List
      CLUSTERED_BY_COL_NAMES, // Return type: java.util.List
      SORT_BY_COL_NAMES, // Return type: java.util.List
      SER_DE_NAME, // Return type: java.lang.String
      SER_DE_LIB_NAME, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      CREATED, // Return type: org.joda.time.Instant
      LAST_ACCESSED, // Return type: org.joda.time.Instant
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    
    com.cloudera.nav.hive.model.HiveViewProperties
    public enum HiveViewProperties implements PropertyEnum {
      DELETED, // Return type: java.lang.Boolean
      QUERY_TEXT, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      CREATED, // Return type: org.joda.time.Instant
      LAST_ACCESSED, // Return type: org.joda.time.Instant
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.mapreduce.model.JobExecutionProperties
    public enum JobExecutionProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      JOB_ID, // Return type: java.lang.String
      ENDED, // Return type: org.joda.time.Instant
      INPUT_RECURSIVE, // Return type: boolean
      TYPE, // Return type: java.lang.String
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      STARTED, // Return type: org.joda.time.Instant
      PRINCIPAL, // Return type: java.lang.String
      WF_INST_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.mapreduce.model.JobProperties
    public enum JobProperties implements PropertyEnum {
      ORIGINAL_NAME, // Return type: java.lang.String
      INPUT_FORMAT, // Return type: java.lang.String
      OUTPUT_FORMAT, // Return type: java.lang.String
      OUTPUT_KEY, // Return type: java.lang.String
      OUTPUT_VALUE, // Return type: java.lang.String
      MAPPER, // Return type: java.lang.String
      REDUCER, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.oozie.model.WorkflowInstanceProperties
    public enum WorkflowInstanceProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      CREATED, // Return type: org.joda.time.Instant
      JOB_ID, // Return type: java.lang.String
      STATUS, // Return type: java.lang.String
      ENDED, // Return type: org.joda.time.Instant
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      STARTED, // Return type: org.joda.time.Instant
      PRINCIPAL, // Return type: java.lang.String
      WF_INST_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.oozie.model.WorkflowProperties
    public enum WorkflowProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.pig.model.PigFieldProperties
    public enum PigFieldProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      INDEX, // Return type: int
      SOURCE_TYPE, // Return type: java.lang.String
      DATA_TYPE, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.pig.model.PigOperationExecutionProperties
    public enum PigOperationExecutionProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      ENDED, // Return type: org.joda.time.Instant
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      STARTED, // Return type: org.joda.time.Instant
      PRINCIPAL, // Return type: java.lang.String
      WF_INST_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.pig.model.PigOperationProperties
    public enum PigOperationProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      OPERATION_TYPE, // Return type: java.lang.String
      SCRIPT_ID, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.pig.model.PigRelationProperties
    public enum PigRelationProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      FILE_SYSTEM_PATH, // Return type: java.lang.String
      SCRIPT_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopExportSubOperationProperties
    public enum SqoopExportSubOperationProperties implements PropertyEnum {
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      INPUTS, // Return type: java.util.Collection
      FIELD_INDEX, // Return type: int
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopImportSubOperationProperties
    public enum SqoopImportSubOperationProperties implements PropertyEnum {
      DB_COLUMN_EXPRESSION, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      INPUTS, // Return type: java.util.Collection
      FIELD_INDEX, // Return type: int
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopOperationExecutionProperties
    public enum SqoopOperationExecutionProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      ENDED, // Return type: org.joda.time.Instant
      INPUTS, // Return type: java.util.Collection
      OUTPUTS, // Return type: java.util.Collection
      STARTED, // Return type: org.joda.time.Instant
      PRINCIPAL, // Return type: java.lang.String
      WF_INST_ID, // Return type: java.lang.String
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopQueryOperationProperties
    public enum SqoopQueryOperationProperties implements PropertyEnum {
      SOURCE_TYPE, // Return type: java.lang.String
      INPUTS, // Return type: java.util.Collection
      QUERY_TEXT, // Return type: java.lang.String
      DB_USER, // Return type: java.lang.String
      DB_URL, // Return type: java.lang.String
      OPERATION_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopTableExportOperationProperties
    public enum SqoopTableExportOperationProperties implements PropertyEnum {
      DB_TABLE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      DB_USER, // Return type: java.lang.String
      DB_URL, // Return type: java.lang.String
      OPERATION_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    com.cloudera.nav.sqoop.model.SqoopTableImportOperationProperties
    public enum SqoopTableImportOperationProperties implements PropertyEnum {                                                                                                            
      DB_TABLE, // Return type: java.lang.String
      DB_WHERE, // Return type: java.lang.String
      SOURCE_TYPE, // Return type: java.lang.String
      DB_USER, // Return type: java.lang.String
      DB_URL, // Return type: java.lang.String
      OPERATION_TYPE, // Return type: java.lang.String
      TYPE, // Return type: java.lang.String
      WF_IDS, // Return type: java.util.Collection
      NAME, // Return type: java.lang.String
      ORIGINAL_NAME, // Return type: java.lang.String
      USER_ENTITY, // Return type: boolean
      SOURCE_ID, // Return type: java.lang.String
      EXTRACTOR_RUN_ID, // Return type: java.lang.String
      PARENT_PATH; // Return type: java.lang.String
    }
    Page generated May 18, 2018.