From commits-return-26594-archive-asf-public=cust-asf.ponee.io@airflow.incubator.apache.org Wed Oct 31 10:17:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3FF9F180789 for ; Wed, 31 Oct 2018 10:17:01 +0100 (CET) Received: (qmail 89081 invoked by uid 500); 31 Oct 2018 09:16:59 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 88769 invoked by uid 99); 31 Oct 2018 09:16:59 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2018 09:16:59 +0000 From: GitBox To: commits@airflow.apache.org Subject: [GitHub] ashb commented on a change in pull request #4111: [AIRFLOW-3266] Add AWS Athena Operator and hook Message-ID: <154097741928.8528.1026827394864744242.gitbox@gitbox.apache.org> Date: Wed, 31 Oct 2018 09:16:59 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit ashb commented on a change in pull request #4111: [AIRFLOW-3266] Add AWS Athena Operator and hook URL: https://github.com/apache/incubator-airflow/pull/4111#discussion_r229610362 ########## File path: airflow/contrib/operators/aws_athena_operator.py ########## @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from airflow.models import BaseOperator +from airflow.utils.decorators import apply_defaults +from airflow.contrib.hooks.aws_athena_hook import AWSAthenaHook + + +class AWSAthenaOperator(BaseOperator): + """ + Airflow operator to run presto queries on athena. + + :param query: Presto to be run on athena. (templated) + :type query: str + :param database: Database to select. (templated) + :type database: str + :param output_location: s3 path to write the query results into. (templated) + :type output_location: str + :param aws_conn_id: aws connection to use. + :type aws_conn_id: str + """ + + ui_color = '#44b5e2' + template_fields = ('query', 'database', 'output_location') + + @apply_defaults + def __init__(self, query, database, output_location, aws_conn_id='aws_default', *args, **kwargs): + super(AWSAthenaOperator, self).__init__(*args, **kwargs) + self.query = query + self.database = database + self.output_location = output_location + self.aws_conn_id = aws_conn_id + self.client_request_token = kwargs.get('client_request_token') + self.query_execution_context = kwargs.get('query_execution_context') or {} + self.result_configuration = kwargs.get('result_configuration') or {} Review comment: All these three kwargs needs to be named parameters so that we don't end up passing unknown parameters to the BaseOperator constructor. And the defaults should be None, not `{}` (as mutable defaults in a function are bad in Python, so this line would become ```suggestion self.result_configuration = result_configuration or {} ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services