zoukankan      html  css  js  c++  java
  • hive与hbase关联表

    关于 hbase 和 hive 关联表 详细介绍:


    hive 创建 关联hbase表有2种形式:

    第一种:
    hive> create table hive(id string,name string, age int)
    > stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > with serdeproperties ("hbase.columns.mapping" = ":key,cf:name,cf:age")
    > tblproperties ("hbase.table.name" = "hbase");

    这种情况是hbase本来没有这张表。hive建表时创建了hbase表.这种情况下,hdfs的hive表目录有hive文件夹,但是里面没有数据(数据时存在hbase里面的)。

    hive> insert overwrite table hive
    > select * from test;
    当hive使用overwrite关键字进行插入数据时。原本数据不会被删除,有同样的行健会被更新覆盖。因为数据是存在hbase中的,遵守hbase插入数据的规则。

    当hive删除hive表时,hbase表也会删除。
    当先删除hbase的时候,先disabled table,然后drop table
    hbase表就被删除了,zookeeper里面也就删除了。
    但是hive里面还在,用show tables还能查出来。mysql中TBLS里面还有hive表的信息。但是用select * from hive 查询的时候报错,表不存在(TableNotFoundException)
    然后删除hive里面的表的时候会报错TableNotFoundException)。继续show tables时,发现表已经不在了。TBLS里面也没有hive表了。


    第二种:external
    hive> create external table hive(id string,name string ,ct string)
    > stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > with serdeproperties ("hbase.columns.mapping" = ":key,cf:name,cf:ct")
    > tblproperties ("hbase.table.name" = "hbase");

    这种情况是hbase里面已经有这张表了,创建一个hive表去管理这hbase表。

    hive> insert overwrite table hive
    > select * from test;
    当hive使用overwrite关键字进行插入数据时。跟第一种情况一样。

    删除hive表对hbase没有影响
    但是先删除hbase表hive就会报TableNotFoundException
    但是删除hive不会报上面这个错。

  • 相关阅读:
    android 四大组件
    apk 反编译
    通过 PC 远程控制 Android 的应用 -- 可以将手机屏幕投射显示到电脑上
    vmware 装 puppy
    vmware 装 puppy
    js prototype 添加属性对象
    js 百度云搜索框
    js 秒杀
    秒杀的性能和超卖
    [JOI2012春季合宿]Rotate (链表)
  • 原文地址:https://www.cnblogs.com/bujunpeng/p/4788279.html
Copyright © 2011-2022 走看看