Code Monkey home page Code Monkey logo

Comments (3)

artwr avatar artwr commented on May 12, 2024

We have an operator that transfers files from s3 to Hive, as well as a Hive to Mysql operator, which is unfortunately missing from the documentation. The hooks being already in place, a s3 to Postgres operator should not be too difficult. Here is an example of how our s3 to Hive operator would work :

from collections import OrderedDict
from airflow.operators import S3ToHiveTransfer

S3ToHiveTransfer(
    task_id='s3_to_hive',
    s3_key='s3://bucket-name/user_list_{{ ds }}.tsv',
    field_dict=OrderedDict([("user_id", "BIGINT")
                            , ("first_name", "STRING")
                            , ("last_name", "STRING")
                            , ("registered_at", "TIMESTAMP")]),
    hive_table='{{ params.db_name }}.user_list_{{ ds_nodash }}',
    create=True,
    recreate=True,
    delimiter='\t',
    s3_conn_id='s3_connection_name',
    dag=dag)

Usually, the transfer is a separate operation of any transform and has its own operator.
I hope this helps.
Best,
Arthur

from airflow.

mistercrunch avatar mistercrunch commented on May 12, 2024

Agreed, the current tutorial is really just focused on the mechanics of Airflow with very foobar-y examples. I didn't want to write a pipeline that was too stack specific (MySQL / Hive / ...) and wanted to make sure it would work for anyone, regardless of the stack they might have.

Maybe using a SqliteOperator to do some analytics on some data scraped from the Internet would be a good example. It could be interesting to re-write the Luigi example for comparison :)

But yeah, it's on the TODO list.

from airflow.

r39132 avatar r39132 commented on May 12, 2024

Cool. I'll close this for now.

from airflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.