title: Airflow BigQuery Operator - Copying One Table to Another Table
body: <p>Using the BigQueryOperator in Airflow, how does one copy a BigQuery table (with a schema of all strings) to another BigQuery table (with a schema of strings, integers and floats)? Note that table_1 and table_2 are already created in BigQuery with the below schemas, and the schemas for table_1 and table_2 should not change.</p>
  <p>table_1 has the following schema and data:</p>
  <pre><code>Column_1 (string)  Column_2 (string)  Column_3 (string)  Column_4 (string)  Column_5 (string)
  ABC                1                  1                  1.5                1
  DEF                2                  2                  2.5                2 
  HIJ                3                  3                  3.5                3 
  </code></pre>
  <p>table_2 has the following schema and data:</p>
  <pre><code>Column_1 (string)  Column_2 (integer) Column_3 (integer) Column_4 (float)  Column_5 (integer)
  ABC                1                  1                  1.5                1
  DEF                2                  2                  2.5                2 
  HIJ                3                  3                  3.5                3 
  </code></pre>
  <p>To accomplish this task, I tried to use the following BigQueryOperator, but got an error message of 'Query column 2 has type STRING which cannot be inserted into column Column_2, which has type INT64'.</p>
  <pre><code>BigQuery_Task = BigQueryOperator(
       task_id = &quot;Copy_To_New_Table&quot;,
       sql = &quot;INSERT `gcp_project.gcp_dataset.table_2` (Column_1, Column_2, Column_3, Column_4, Column_5) SELECT Column_1, Column_2, Column_3, Column_4, Column_5 FROM `gcp_project.gcp_dataset.table_1`&quot;, 
       write_disposition = &quot;WRITE_TRUNCATE&quot;,
       location = &quot;US&quot;, 
       bigquery_conn_id = &quot;conn_id&quot;,
       use_legacy_sql = False, 
       dag = dag)
  
  </code></pre>