V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2019-08-27 16:34:29 +08:00 · 917 次点击
    这是一个创建于 1703 天前的主题,其中的信息可能已经有所发展或是发生改变。

    场景:有一张 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
       2019-08-28 09:32:02 +08:00
    别沉啊,求教
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3610 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:22 · PVG 12:22 · LAX 21:22 · JFK 00:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.