FILE_NAME
Description
FILE_NAME
is a row function that returns the original file name from
the source file system. This is useful when the source data that comprises a dataset
comes from multiple files, and there is useful information in the file names themselves
(such as dates or server names). You can use FILE_NAME
in combination
with other text processing functions to extract useful information from the file
name.Syntax
FILE_NAME
()Return Value
Returns one value per row of type
Text
.Examples
Your dataset is based on daily log files that use an 8 character date as part of the file
name. For example,
20120704.log
is the file name used for the log file created on
July 4, 2012. The following expression uses FILE_NAME
in combination with
SUBSTRING
and
TO_DATE
to create a date
field from the first 8 characters of the file name.TO_DATE(SUBSTRING(FILE_NAME(),0,8),"yyyyMMdd")
Your dataset is based on log files that use the server IP address as part of the file name.
For example,
172.12.131.118.log
is the log file name for server 172.12.131.118. The
following expression uses FILE_NAME
in combination with
REGEX
to extract the IP address from the file name.REGEX(FILE_NAME(),"
(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
\.log")