title: PYSPARK org.apache.spark.sql.AnalysisException: cannot resolve '`INPUT__FILE__NAME`' given input columns
body: <p>I using configuration file as below :</p>
  <pre><code>&quot;trial&quot;:{
              &quot;stage_table&quot;: &quot;trial_stg&quot;,
              &quot;folder_location&quot;: &quot;Trial&quot;,
              &quot;column_mapping&quot;: [
              {
                &quot;source_column&quot;: &quot;(split(INPUT__FILE__NAME, '\\/')[11])&quot;,
                &quot;source_datatype&quot;: &quot;text&quot;,
                &quot;target_column&quot;: &quot;indication&quot;,
                &quot;target_datatype&quot;: &quot;text&quot;,
                &quot;transform_type&quot;: &quot;expression&quot;,
                &quot;validate&quot;: false
              }
  </code></pre>
  <p>I am trying to get file name using INPUT__FILE__NAME function in pyspark but I am getting issue.
  Below is the code after reading this config file :</p>
  <pre><code>def query_expression_builder(mapping):
      print(&quot;Inside query_expression_builder&quot;)
      print(&quot;mapping :&quot;,mapping)
  
      def match_transform_type(map_col):
          print(&quot;Inside match_transform_type&quot;)
  
          if map_col.get('transform_type') is None:
              print(&quot;transform_type is&quot;,map_col.get('transform_type'))
              print(&quot;map_col  inside if :&quot;,map_col)
                          
              return f&quot;`{map_col['source_column']}` AS {map_col['target_column']}&quot;
  
          elif str(map_col.get('transform_type')).__eq__('expression'):
              print(&quot;transform_type is&quot;,map_col.get('transform_type'))
              print(&quot;map_col  inside elif :&quot;,map_col)
  
              return f&quot;{map_col['source_column']} AS {map_col['target_column']}&quot;
  
          else:
              print(&quot;transform_type is&quot;,map_col.get('transform_type'))
              print(&quot;map_col  inside else :&quot;,map_col)
  
              return f&quot;`{map_col['source_column']}` AS {map_col['target_column']}&quot;
  
      if mapping is None:
          print(&quot;Check for mapping is None&quot;)
  
  
           return []
          else:
              print(&quot;Mapping is not None&quot;)            
  return list(map(lambda col_mapping: match_transform_type(map_col=col_mapping), mapping))
  
  
  
  def main():
  
  query = query_expression_builder\
                              (mapping=config['file_table_mapping'][tbl]['column_mapping'])
                          print(f&quot;Table = {tbl} Executing query {query}&quot;)
                              file_path = f&quot;s3://{config['raw_bucket']}/{config['landing_directory']}/{config['file_table_mapping'][tbl]['folder_location']}/{config_audit['watermark_timestamp']}*.csv&quot;
                              write_df = spark.read.csv(path=file_path, header=True,\
                                                        inferSchema=False).selectExpr(query) \
                                  .withColumn(&quot;prcs_run_id&quot;, func.lit(config_audit['prcs_run_id']))\
                                  .withColumn(&quot;job_run_id&quot;,\
                                  func.lit(config_audit['job_run_id']))\
                                  .withColumn(&quot;ins_ts&quot;, func.lit(ins_ts))\
                                  .withColumn(&quot;rec_crt_user&quot;, func.lit(config[&quot;username&quot;]))
                              write_df.show()
  </code></pre>
  <p>Below is the error I am getting :</p>
  <pre><code>&quot;cannot resolve '`INPUT__FILE__NAME`' given input columns: [Pediatric Patients included (Y/N), Trial registry number, Number of patients, Sponsor, Number of treatment arms, Multicenter study, Trial Conclusion, Clinical Phase, Study Population, Country Codes, Exclusion criteria, Trial ID, Trial AcronymDerived, Comments, Countries, Trial registry name, Sample size calculation details, Randomisation, Blinding, Trial Comments, Trial start year, Trial end year, Inclusion criteria, Study treatment, Trial design, Controlled trial, Trial Acronym, Trial Control, Asymptomatic patients, Analysis method details]; line 1 pos 7;\n'Project ['split('INPUT__FILE__NAME, /)[11] AS indication#4346, Trial ID#4286 AS trial_id#4347, Trial Acronym#4287 AS trial_acronym#4348, Trial AcronymDerived#4288 AS trial_acronym_derived#4349, Sponsor#4289 AS sponsor#4350, Asymptomatic patients#4290 AS asymptomatic_patients#4351, Pediatric Patients included (Y/N)#4291 AS pediatric_patients_included#4352, Number of patients#4292 AS num_of_patients#4353, Number of treatment arms#4293 AS num_of_treatment_arms#4354, Trial start year#4294 AS trial_strt_yr#4355, Trial end year#4295 AS trial_end_yr#4356, Clinical Phase#4296 AS clinical_phase#4357, Study Population#4297 AS study_population#4358, Study treatment#4298 AS study_treatment#4359, Randomisation#4299 AS randomization#4360, Controlled trial#4300 AS controlled_trial#4361, Trial Control#4301 AS trial_control#4362, Blinding#4302 AS blinding#4363, Trial registry name#4303 AS trial_registry_name#4364, Trial registry number#4304 AS trial_registry_num#4365, Countries#4305 AS countries#4366, Country Codes#4306 AS country_codes#4367, Trial design#4307 AS trial_design#4368, Multicenter study#4308 AS multicenter_study#4369, ... 7 more fields]\n+- Relation[Trial ID#4286,Trial Acronym#4287,Trial AcronymDerived#4288,Sponsor#4289,Asymptomatic patients#4290,Pediatric Patients included (Y/N)#4291,Number of patients#4292,Number of treatment arms#4293,Trial start year#4294,Trial end year#4295,Clinical Phase#4296,Study Population#4297,Study treatment#4298,Randomisation#4299,Controlled trial#4300,Trial Control#4301,Blinding#4302,Trial registry name#4303,Trial registry number#4304,Countries#4305,Country Codes#4306,Trial design#4307,Multicenter study#4308,Inclusion criteria#4309,... 6 more fields] csv\n&quot;
  Traceback (most recent call last):
    File &quot;/mnt/yarn/usercache/root/appcache/application_1594568207850_0001/container_1594568207850_0001_01_000001/pyspark.zip/pyspark/sql/utils.py&quot;, line 63, in deco
      return f(*a, **kw)
    File &quot;/mnt/yarn/usercache/root/appcache/application_1594568207850_0001/container_1594568207850_0001_01_000001/py4j-0.10.7-src.zip/py4j/protocol.py&quot;, line 328, in get_return_value
      format(target_id, &quot;.&quot;, name), value)
  py4j.protocol.Py4JJavaError: An error occurred while calling o529.selectExpr.
  : org.apache.spark.sql.AnalysisException: cannot resolve '`INPUT__FILE__NAME`' given input columns:
  </code></pre>
  <p>How can I use INPUT__FILE__NAME function? I have already enabled hive support in my code. Or is there any other way to do this? I cannot find anything on net on how to use this function.</p>