I am trying to get filenames(file format:json.gz) using input_filename() function in pyspark. Below is the code:
df.withColumn("source_file",sql_f.element_at(sql_f.split(sql_f.input_file_name(), "/"), -1)
It returns an empty string. Below is the screenshot:
I have tried to get the filename by simply using input_file_name() as well:
df.withColumn("source_file",sql_f.input_file_name())
Any help will be highly appreciated.