Skip to content

Commit

Permalink
Merge pull request apache#35 in DI/airflow from more_sql_escape_nonse…
Browse files Browse the repository at this point in the history
…nse to 1.10.4-wepay

Squashed commit of the following:

commit 58aa4e49db407a26b9a3d3c94a635e9297b798c0
Author: Moira Tagle <moirat@wepay.com>
Date:   Fri Feb 21 10:29:13 2020 -0800

    just use legacy sql escaping.

    I'm honestly not sure why my previous approach didn't work, but clearly it didn't.
    As far as I can tell the hook (and thus the cursor) will always use legacy SQL, so I'm just
    going to use the legacy SQL escaping format rather than trying to be clever.
  • Loading branch information
mtagle committed Feb 21, 2020
1 parent f9d8e6f commit 716649a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions airflow/contrib/operators/gcs_to_bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,10 @@ def execute(self, context):
time_partitioning=self.time_partitioning,
cluster_fields=self.cluster_fields)

if bq_hook.use_legacy_sql:
escaped_table_name = '[{}]'.format(self.destination_project_dataset_table)
else:
escaped_table_name = '`{}`'.format(self.destination_project_dataset_table)
if self.max_id_key:
cursor.execute('SELECT MAX({}) FROM {}'.format(
cursor.execute('SELECT MAX({}) FROM [{}]'.format(
self.max_id_key,
escaped_table_name))
self.destination_project_dataset_table))
row = cursor.fetchone()
max_id = row[0] if row[0] else 0
self.log.info(
Expand Down

0 comments on commit 716649a

Please sign in to comment.