Support Questions
Find answers, ask questions, and share your expertise

How to append current date to file path in Pig

Rising Star

How can I get the current date so that I can append it in dynamically changing file paths or in FILTER statements in PigLatin scripts? E.g. A = LOAD '/data/$current_date/file.csv' ;

B = FILTER relation1 BY Date == ($current_date-1);

1 REPLY 1

Expert Contributor

@Kibrom Gebrehiwot

%default current_date `date +%Y-%m-%d`; (This will create the date in yyyy-mm-dd format)

now you can refer the date by inserting $current_date in the string:

LOAD '/data/$current_date/file.csv' ;