BigQueryOperator:对于参数类型:DATE,INT64,运算符=没有匹配的签名

时间:2018-09-02 10:56:12

标签: google-bigquery airflow

当我在BigQuery UI上运行此查询时:

urlpatterns

查询效果很好。 但是,当我尝试在Airflow上进行操作时:

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', HomePageView.as_view(), name='home-page'),
    url(r'^teams/$', TeamsListView.as_view(), name='teams-list-view'),
    url(r'^scores/$', ScoresListView.as_view(), name='scores-list-view'),
    url(r'^player/[?P<slug>[-\w\x20]+]/$', PlayerDetailView.as_view(), name='player-detail-view'),
]

它返回:

DELETE FROM `A.Books.items` where Date='2018-08-31'

delete_sql = '''DELETE FROM `A.Books.items` where Date = {0}'''.format('2018-08-31') # // later this will be variable delete_old= BigQueryOperator( task_id='bigquery_delete', bql=delete_sql, destination_dataset_table=False, bigquery_conn_id=CONNECTION_ID, delegate_to=False, use_legacy_sql = 'False', udf_config=False, dag=dag, ) Exception: BigQuery job failed. Final error was: {u'reason': u'invalidQuery', u'message': u'No matching signature for operator = for argument types: DATE, INT64. Supported signatures: ANY = ANY at [1:52]', u'location': u'query' 表中类型为Date的列。

如何解决此错误?

1 个答案:

答案 0 :(得分:3)

以下方法应该起作用:

delete_sql = '''DELETE FROM A.Books.items where Date = '{0}' '''.format('2018-08-31')

要替换字符串时,需要用引号引起来。