zoukankan      html  css  js  c++  java
  • pig笔记

    1.安装Pig
    将pig添加到环境变量当中

    2.pig使用
    首先将数据库中的数据导入到HDFS上
    sqoop import --connect jdbc:mysql://192.168.1.10:3306/cloud --username root --


    password JChubby123  --table trade_detail --target-dir '/sqoop/td'
    sqoop import --connect jdbc:mysql://192.168.1.10:3306/cloud --username root --


    password JChubby123  --table user_info --target-dir '/sqoop/ui'
     

    td = load '/sqoop/td' using PigStorage(',') as (id:long, account:chararray, 


    income:double, expenses:double, time:chararray);
    ui = load '/sqoop/ui' using PigStorage(',') as (id:long, account:chararray, 


    name:chararray, age:int);

    td1 = foreach td generate account, income, expenses, income-expenses as surplus;

    td2 = group td1 by account;

    td3 = foreach td2 generate group as account, SUM(td1.income) as income, SUM


    (td1.expenses) as expenses, SUM(td1.surplus) as surplus;

    tu = join td3 by account, ui by account;

    result = foreach tu generate td3::account as account, ui::name, td3::income, 


    td3::expenses, td3::surplus;

    store result into '/result' using PigStorage(',');
  • 相关阅读:
    js中null " "的区别
    简略的地图API应用
    JSON的一个例子(代码来源于网上)
    浅谈Event Flow、Process、Method及其Applications
    JS中object与constructor的分析
    浅谈for...in与for....of
    浅谈语言的过去与未来
    正则表达式的四个小应用
    BOM详细
    BOM
  • 原文地址:https://www.cnblogs.com/jchubby/p/4429688.html
Copyright © 2011-2022 走看看