CURRENT_LOAD_SOURCE
When called within the scope of a COPY statement, returns the file name or path part used for the load.
When called within the scope of a COPY statement, returns the file name used for the load. With an optional integer argument, it returns the Nth /
-delimited path part.
If the function is called outside of the context of a COPY
statement, it returns NULL.
If the current load uses a UDSource function that does not set the URI, CURRENT_LOAD_SOURCE returns the string UNKNOWN
. You cannot call CURRENT_LOAD_SOURCE(INT) when using a UDSource.
Behavior type
StableSyntax
CURRENT_LOAD_SOURCE( [ position ])
Arguments
position
(positive INTEGER)- Path element to return instead of returning the full path. Elements are separated by slashes (
/
) and the first element is position 1. If the value is greater than the number of elements, the function returns an error. You cannot use this argument with a UDSource function.
Examples
The following load statement populates a column with the name of the file the row was loaded from:
The following example reads year and month columns out of a path: