gpt4 book ai didi

hbase - 如何将 Hive 表与 HBase 表映射?

转载 作者:行者123 更新时间:2023-12-04 18:44:08 25 4
gpt4 key购买 nike

我创建了一个 HBase 表,如下所示:

create 'nancy', 'cf'


并在 Hive 中创建了一个表,如下所示:

create external table nancy( id int, name string)

stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key, cf:name")

TBLPROPERTIES("hbase.table.name"="nancy");


我在映射它写吗? “hbase.columns.mapping”中的Key是什么意思?
谁能解释一下这个映射?

最佳答案

您是否面临任何特定问题?查询对我来说很好。

key 表示您正在使用此字段作为表键。记住 hive 表中的每个字段都可以映射到以下字段之一:

  • 表键(使用 :key 作为选择器)
  • 列族 (cf:)(Hive 中的 MAP 字段
  • 栏目

  • 回复您的意见:
    hive> CREATE EXTERNAL TABLE hbase_table_2(key int, name string)

    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:name")
    > TBLPROPERTIES("hbase.table.name" = "nancy");
    OK
    Time taken: 5.106 seconds

    hive> select * from hbase_table_2;
    OK
    Time taken: 0.077 seconds

    hive> INSERT OVERWRITE TABLE hbase_table_2 SELECT * FROM demo WHERE id=1;
    Total MapReduce jobs = 1
    Launching Job 1 out of 1
    Number of reduce tasks is set to 0 since there's no reduce operator
    Starting Job = job_201308011237_0003, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201308011237_0003
    Kill Command = /Users/miqbal1/hadoop-eco/hadoop-1.1.2/libexec/../bin/hadoop job -kill job_201308011237_0003
    Hadoop job information for Stage-0: number of mappers: 1; number of reducers: 0
    2013-08-01 16:29:21,832 Stage-0 map = 0%, reduce = 0%
    2013-08-01 16:29:23,843 Stage-0 map = 100%, reduce = 0%
    2013-08-01 16:29:24,849 Stage-0 map = 100%, reduce = 100%
    Ended Job = job_201308011237_0003
    1 Rows loaded to hbase_table_2
    MapReduce Jobs Launched:
    Job 0: Map: 1 HDFS Read: 256 HDFS Write: 0 SUCCESS
    Total MapReduce CPU Time Spent: 0 msec
    OK
    Time taken: 8.392 seconds
    hive>

    这是我的 HBase 表:
    hbase(main):017:0> scan 'nancy'
    ROW COLUMN+CELL
    1 column=cf:name, timestamp=1375354762803, value=tariq
    1 row(s) in 0.0300 seconds

    关于hbase - 如何将 Hive 表与 HBase 表映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17986435/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com