title: Apache beam - Google Dataflow - WriteToBigQuery - Python - Parameters - Templates - Pipelines
body: <p>I have 2 questions on my development.</p>
  <p><strong>Question 1</strong></p>
  <p>I'm trying to create a template from a python code which consists of reading from BigQuery tables, apply some transformations and write in a different BigQuery table (which can exists or not).</p>
  <p>The point is that I need to send the target table as parameter, but looks that I can't use parameters in the pipeline method WriteToBigQuery as it is raising the following error message: apache_beam.error.RuntimeValueProviderError: RuntimeValueProvider(option: project_target, type: str, default_value: 'Test').get() not called from a runtime context</p>
  <p><em>Approach 1</em></p>
  <pre><code>with beam.Pipeline(options=options) as pipeline:
      logging.info(&quot;Start logic process...&quot;)
      kpis_report = (
              pipeline
              | &quot;Process start&quot; &gt;&gt; Create([&quot;1&quot;])
              | &quot;Delete previous data&quot; &gt;&gt; ParDo(preTasks())
              | &quot;Read table&quot; &gt;&gt; ParDo(readTable())
              ....
              | 'Write table 2' &gt;&gt; Write(WriteToBigQuery(
                 table=custom_options.project_target.get() + &quot;:&quot; + custom_options.dataset_target.get() + &quot;.&quot; + custom_options.table_target.get(),
          schema=custom_options.target_schema.get(),
          write_disposition=BigQueryDisposition.WRITE_APPEND,
          create_disposition=BigQueryDisposition.CREATE_IF_NEEDED)
  </code></pre>
  <p><em>Approach 2</em></p>
  <p>I created a ParDo function in order to get there the variable and set the WriteToBigQuery method. However, despite of having the pipeline execution completed sucessfully and seeing that the output is returning rows (theoretically written), I can't see the table nor data inserted on it.</p>
  <pre><code>    with beam.Pipeline(options=options) as pipeline:
      logging.info(&quot;Start logic process...&quot;)
      kpis_report = (
              pipeline
              | &quot;Process start&quot; &gt;&gt; Create([&quot;1&quot;])
              | &quot;Pre-tasks&quot; &gt;&gt; ParDo(preTasks())
              | &quot;Read table&quot; &gt;&gt; ParDo(readTable())
              ....
  
              | 'Write table 2' &gt;&gt; Write(WriteToBigQuery())
  </code></pre>
  <p>Where I tried with 2 methods and none works: BigQueryBatchFileLoads and WriteToBigQuery</p>
  <pre><code>class writeTable(beam.DoFn):
  def process(self, element):
      try:
          #Load first here the parameters from the custom_options variable (Here we can do it)
  
          result1 = Write(BigQueryBatchFileLoads(destination=target_table,
                                       schema=target_schema,
                                       write_disposition=BigQueryDisposition.WRITE_APPEND,
                                       create_disposition=BigQueryDisposition.CREATE_IF_NEEDED))
          
          result2 = WriteToBigQuery(table=target_table,
                          schema=target_schema,
                          write_disposition=BigQueryDisposition.WRITE_APPEND,
                          create_disposition=BigQueryDisposition.CREATE_IF_NEEDED,
                          method=&quot;FILE_LOADS&quot;
                          ) 
  </code></pre>
  <p><strong>Question 2</strong></p>
  <p>Other doubt I have is if in this last ParDo class, I need to return something as the element or result1 or result2 as we are in the last pipeline step.</p>
  <p>Appreciate your help on this.</p>