Why does CURRENT_LOAD_SOURCE() return "Batch No. 1" instead of the actual source file name? I'm loading some data into a table like this:

COPY table1 (
    col1,
    col2,
    file_name AS CURRENT_LOAD_SOURCE()
)
FROM LOCAL :src_file
REJECTED DATA :rejected_file
EXCEPTIONS :exceptions_file
SKIP 1;


It works, except file_name gets populated with the string Batch No. 1 instead of the actual base name of :src_file.

The doc for CURRENT_LOAD_SOURCE() doesn't explain why this happening.

Is this a bug? How do I get the actual name of the source file?
This certainly looks like a bug, whether you want to characterize it as an oversight, unfinished feature, or something else.

Vertica support tells me this is a known issue and a fix is being tracked as part of VER-36735. (Unfortunately, their issue tracker is not visible to the public.)

The problem appears to be related to the LOCAL clause, which is used to load files that are on the client machine as opposed to the server.

If you remove the LOCAL clause (and put the files you are loading on the server), then CURRENT_LOAD_SOURCE() will return the file name of the file being loaded, as expected.

COPY table1 (
    col1,
    col2,
    file_name AS CURRENT_LOAD_SOURCE()
)
FROM :src_file  -- no LOCAL!
REJECTED DATA :rejected_file
EXCEPTIONS :exceptions_file
SKIP 1;


If you're stuck with the LOCAL, then your best bet is to simply pass in a new variable (e.g. :file_name) that you explicitly set with the name of the file you are loading. You'll just need to be sure to provide the base name of the file (as opposed to the full path), to match the intended behavior of CURRENT_LOAD_SOURCE().