You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/04/06 19:39:51 UTC

[GitHub] [airflow] eladkal opened a new pull request #8167: add PrestoOperator

eladkal opened a new pull request #8167: add PrestoOperator
URL: https://github.com/apache/airflow/pull/8167
 
 
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [airflow] mik-laj commented on a change in pull request #8167: add PrestoOperator

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #8167: add PrestoOperator
URL: https://github.com/apache/airflow/pull/8167#discussion_r404347048
 
 

 ##########
 File path: airflow/providers/presto/operators/presto.py
 ##########
 @@ -0,0 +1,71 @@
+#
+# 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 typing import Iterable, Mapping, Optional, Union
+
+from airflow.models import BaseOperator
+from airflow.providers.presto.hooks.presto import PrestoHook
+from airflow.utils.decorators import apply_defaults
+
+
+class PrestoOperator(BaseOperator):
+    """
+    Executes sql code in a specific Presto database
+
+    :param sql: the sql code to be executed. Can receive a str representing a
+        sql statement, a list of str (sql statements), or reference to a template file.
+        Template reference are recognized by str ending in '.sql'
+        (templated)
+    :type sql: str or list[str]
+    :param presto_conn_id: reference to a specific presto database
+    :type presto_conn_id: str
+    :param parameters: (optional) the parameters to render the SQL query with.
+    :type parameters: mapping or iterable
+    :param catalog: name of catalog which overwrite defined one in connection
+    :type catalog: str
+    :param schema: name of schema which overwrite defined one in connection
+    :type schema: str
+    """
+
+    template_fields = ('sql',)
+    template_ext = ('.sql',)
+    ui_color = '#ededed'
+
+    @apply_defaults
+    def __init__(
+            self,
+            sql: str,
+            presto_conn_id: str = 'presto_default',
+            parameters: Optional[Union[Mapping, Iterable]] = None,
+            catalog: Optional[str] = None,
+            schema: Optional[str] = None,
+            *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.presto_conn_id = presto_conn_id
+        self.sql = sql
+        self.parameters = parameters
+        self.catalog = catalog
+        self.schema = schema
+
+    def execute(self, context):
+        self.log.info('Executing: %s', self.sql)
+        hook = PrestoHook(presto_conn_id=self.presto_conn_id,
 
 Review comment:
   Can you look at this PR?
   https://github.com/apache/airflow/pull/3891/files

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

[GitHub] [airflow] mik-laj commented on issue #8167: add PrestoOperator

Posted by GitBox <gi...@apache.org>.
mik-laj commented on issue #8167: add PrestoOperator
URL: https://github.com/apache/airflow/pull/8167#issuecomment-609999193
 
 
   Are these operators really working? I had a problem with the run method.
   Please look at: https://github.com/apache/airflow/blob/master/tests/providers/google/cloud/operators/test_presto_to_gcs_system.py#L137-L141
   
   Could you add system tests and a sample DAG? This would make it easier to test these operators.
   You can base on:
   https://github.com/apache/airflow/blob/master/tests/providers/google/cloud/operators/test_presto_to_gcs_system.py

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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