Directory Templates
By default, the Hadoop FS destination uses directory templates to create output and late record directories. Hadoop FS writes records to the directories based on the configured time basis.
You can alternatively write records to directories based
on the targetDirectory
record header attribute. Using the
targetDirectory
attribute disables the ability to define
directory templates.
When you define a directory template, you can use a mix
of constants, field values, and datetime variables. You can use the
every
function to create new directories at regular
intervals based on hours, minutes, or seconds, starting on the hour. You can also
use the record:valueOrDefault
function to create new directories
from field values or a default in the directory template.
/outputfiles/${record:valueOrDefault("/State", "unknown")}/${YY()}-${MM()}-${DD()}-${hh()}
- Constants
- You can use any constant, such as
output
. - Datetime Variables
- You can use datetime variables, such as
${YYYY()}
or${DD()}
. The destination creates directories as needed, based on the smallest datetime variable that you use. For example, if the smallest variable is hours, then the directories are created for every hour of the day that receives output records. every
function- You can use the
every
function in a directory template to create directories at regular intervals based on hours, minutes, or seconds, beginning on the hour. The intervals should be a submultiple or integer factor of 60. For example, you can create directories every 15 minutes or 30 seconds. record:valueOrDefault
function- You can use the
record:valueOrDefault
function in a directory template to create directories with the value of a field or the specified default value if the field does not exist or if the field is null:${record:valueOrDefault(<field path>, <default value>)}