zoukankan      html  css  js  c++  java
  • Hive数据提取

    Hive是基于Hadoop的ETL工具和数据仓库。

    结构化数据

    结构化数据就像RDBMS

    hive> create table structured_table(id int, name string)
        > row format delimited
        > fields terminated by ','
        > location '/yandufeng/structured_table';
    OK
    Time taken: 0.209 seconds
    hive> load data local inpath '/home/hive/test2.txt' into table structured_table;
    Loading data to table default.structured_table
    Table default.structured_table stats: [numFiles=1, totalSize=23]
    OK
    Time taken: 0.831 seconds
    hive> select * from structured_table;
    OK
    1    hello
    2    name
    3    world
    Time taken: 0.106 seconds, Fetched: 3 row(s)

    半结构化的数据,例如:json,xml

    hive> 
        > create table json_table(str string);
    OK
    Time taken: 0.229 seconds
    hive> load data local inpath '/home/hive/json_table.json' into table json_table;
    Loading data to table default.json_table
    Table default.json_table stats: [numFiles=1, totalSize=26]
    OK
    Time taken: 1.523 seconds
    hive> select get_json_object(str, '$.a') from json_table;
    OK
    2
    Time taken: 0.168 seconds, Fetched: 1 row(s)
    hive> select get_json_object(str, '$.a'), get_json_object(str, '$.b') from json_table;
    OK
    2    blah
    Time taken: 0.084 seconds, Fetched: 1 row(s)

     什么时候使用Hive

    • 当需要强大的统计方法的时候
    • 当要处理结构化或者半结构化数据
    • 当需要基于Hadoop的数据仓库
    • 可以于Hbase结合

    Hive用在什么地方

    • 作为ETL工具和数据仓库
    • 提供HQL进行数据查询
    • 为特定的需求,用自定义的map和reduce脚本
  • 相关阅读:
    TCHAR字符串查找&反向查找字符串
    如何判断一个文本文件的编码
    用NETSH WINSOCK RESET命令修复网络
    #define和typedef在windows上的应用
    Visual Studio Code (vscode)编译C++
    win32 Message(MSG)消息处理
    HBRUSH to RGB value
    InvalidateRect和UpdateWindow
    Informatic ETL开发步骤
    【非官方方式】获取Disconf动态更新的配置文件的值
  • 原文地址:https://www.cnblogs.com/yandufeng/p/6433622.html
Copyright © 2011-2022 走看看