[ 
https://issues.apache.org/jira/browse/AIRFLOW-3355?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kaxil Naik updated AIRFLOW-3355:
--------------------------------
    Fix Version/s:     (was: 2.0.0)
                   1.10.2

> Fix BigQueryCursor.execute to work with Python3
> -----------------------------------------------
>
>                 Key: AIRFLOW-3355
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3355
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: gcp, hooks
>            Reporter: Kengo Seki
>            Assignee: Kengo Seki
>            Priority: Major
>             Fix For: 1.10.2
>
>
> {{BigQueryCursor.execute}} uses {{dict.iteritems}} internally, so it fails 
> with Python3 if binding parameters are provided.
> {code}
> In [1]: import sys
> In [2]: sys.version
> Out[2]: '3.6.6 (default, Sep 12 2018, 18:26:19) \n[GCC 8.0.1 20180414 
> (experimental) [trunk revision 259383]]'
> In [3]: from airflow.contrib.hooks.bigquery_hook import BigQueryHook
> In [4]: hook = BigQueryHook()
> In [5]: conn = hook.get_conn()
> [2018-11-15 19:01:35,856] {discovery.py:267} INFO - URL being requested: GET 
> https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest
> In [6]: cur = conn.cursor()
> In [7]: cur.execute("SELECT count(*) FROM ds.t WHERE c = %(v)d", {"v": 0})
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-7-54c59af50270> in <module>
> ----> 1 cur.execute("SELECT count(*) FROM ds.t WHERE c = %(v)d", {"v": 0})
> ~/dev/incubator-airflow/airflow/contrib/hooks/bigquery_hook.py in 
> execute(self, operation, parameters)
>    1561         """
>    1562         sql = _bind_parameters(operation,
> -> 1563                                parameters) if parameters else 
> operation
>    1564         self.job_id = self.run_query(sql)
>    1565
> ~/dev/incubator-airflow/airflow/contrib/hooks/bigquery_hook.py in 
> _bind_parameters(operation, parameters)
>    1684     # inspired by MySQL Python Connector (conversion.py)
>    1685     string_parameters = {}
> -> 1686     for (name, value) in parameters.iteritems():
>    1687         if value is None:
>    1688             string_parameters[name] = 'NULL'
> AttributeError: 'dict' object has no attribute 'iteritems'
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to