推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
maijh
V2EX  ›  Python

请教一个插表 etl 问题

  •  
  •   maijh · Aug 27, 2019 · 2076 views
    This topic created in 2588 days ago, the information mentioned may be changed or developed.

    场景:有一张 union 汇总表(假设表名 m_union ),可能需要多张源表(假设表名 s1,s2,s3...)插进去,请教下大家一般是怎么处理的? 或者有什么开源工具框架推荐? 方法 1: insert into m_union select column1,column2,type from ( select column1,column2,'s1' type from s1 union all select column1,column2,'s2' type from s2 union all select column1,column2,'s3' type from s3 ... .... ..... )a 这种是要等所有源表都入好当天数据才能一次性插到 m_union,优点是一个 etl 任务,但缺点时效性晚,而且初衷是想只要一张源表入好就插进去 m 表里。 方法 2: insert into m_union
    select column1,column2,'s1' type from s1; insert into m_union
    select column1,column2,'s2' type from s2; insert into m_union
    select column1,column2,'s3' type from s3; ... .... ..... 这种可以满足初衷是想只要一张源表入好就插进去 m 表里。但要写很多个 etl 插入任务,而且一个 sql 一个脚本,而且如果是十来二十多张或更多源表就更泪奔了。 方法 3:求大神们的好方法。

    maijh
        1
    maijh  
    OP
       Aug 28, 2019
    别沉啊,求教
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   841 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 22:21 · PVG 06:21 · LAX 15:21 · JFK 18:21
    ♥ Do have faith in what you're doing.