0

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: enter image description here

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.

Nabeel Khan Ghauri
  • 125
  • 1
  • 4
  • 15

0 Answers0