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不会报上面这个错。

  • 相关阅读:
    SQLite 版本引发的 Python 程序调用问题
    从0到10亿,微信后台架构及基础设施设计与实践!
    从Oracle到PostgreSQL:动态性能视图 vs 标准统计视图
    第一章 准备工作
    Swagger2简介
    如何查询numpy,scipy,matplotlib等的版本和安装位置
    完美解决ImportError: cannot import name '_validate_lengths'报错问题
    完美解决AttributeError: module 'scipy.misc' has no attribute 'imread'报错问题
    线上课堂:ernetes Operator开发范式
    Bomb Enemy 炸弹人
  • 原文地址:https://www.cnblogs.com/bujunpeng/p/4788279.html
Copyright © 2011-2022 走看看