【问题标题】:BigSQL-HBase IntegrationBigSQL-HBase 集成
【发布时间】:2016-01-13 09:44:27
【问题描述】:

我是 BigSQL 的新手。我开始知道 HBase 可以与 BigSQL 集成。我曾尝试在创建 HBase 表之后和之前执行 BigSQL-HBase 创建命令,但我收到了下面提到的错误。

SQL1:

CREATE HBASE TABLE dbname.reviews_hive (
REVIEWID int,
PRODUCT int
)
COLUMN MAPPING
(
key MAPPED BY (REVIEWID),
summary:product MAPPED BY (PRODUCT)
);

(或)

SQL2:

CREATE HBASE TABLE dbname.reviews_hive (
REVIEWID int primary key not null,
PRODUCT int
)
COLUMN MAPPING
(
key MAPPED BY (REVIEWID),
summary:product MAPPED BY (PRODUCT)
);

错误:[状态:42601][代码:-104]:发现意外的令牌“密钥” 在“(”之后。预期的标记可能包括:“”.. SQLCODE=-104, SQLSTATE=42601,驱动程序=3.68.61

谁能帮我解决这个问题?

提前谢谢各位。

【问题讨论】:

    标签: hadoop hbase bigsql


    【解决方案1】:

    我假设您使用的是 Big Insights 4.x。在 BigInsights 4 之前,Big SQL 的 SQL 接口仅在 BigSQL v1 中可用。

    当我运行以下测试脚本(包括您的两个 CREATE HBASE TABLE 语句)(我通过 jsqsh db2 命令行运行此示例)时,我得到这些结果:

    \connect bigsql
    drop table if exists stack.issue3;
    
    create hbase table if not exists stack.issue3 (
    f1 integer,
    f2 integer,
    f3 varchar(200),
    f4 integer
    )
    column mapping(
        key mapped by (f1, f2),
        cf0:f3 mapped by (f3,f4)
        encoding delimited
        fields terminated by '\b'
    )
    default encoding binary
    ;
    
    insert into stack.issue3 (f1,f2,f3,f4) values (0,0,'Detroit',0);
    insert into stack.issue3 (f1,f2,f3,f4) values (1,1,'Mt. Pleasant',1);
    insert into stack.issue3 (f1,f2,f3,f4) values (2,2,'Marysville',2);
    insert into stack.issue3 (f1,f2,f3,f4) values (3,3,'St. Clair',3);
    insert into stack.issue3 (f1,f2,f3,f4) values (4,4,'Port Huron',4);
    
    select * from stack.issue3;
    
    drop table if exists dbname.reviews_hive;
    CREATE HBASE TABLE if not exists dbname.reviews_hive (
            REVIEWID int,
            PRODUCT int
    )
    COLUMN MAPPING (
    key MAPPED BY (REVIEWID),
    summary:product MAPPED BY (PRODUCT)
    );
    
    insert into dbname.reviews_hive(reviewid,product) values (0,0);
    insert into dbname.reviews_hive(reviewid,product) values (1,1);
    insert into dbname.reviews_hive(reviewid,product) values (2,2);
    insert into dbname.reviews_hive(reviewid,product) values (3,3);
    
    select * from dbname.reviews_hive;
    
    
    drop table if exists dbname.reviews_hive1;
    CREATE HBASE TABLE if not exists dbname.reviews_hive1 (
            REVIEWID int primary key not null,
            PRODUCT int
    )
    COLUMN MAPPING (
            key MAPPED BY (REVIEWID),
            summary:product MAPPED BY (PRODUCT)
    );
    
    insert into dbname.reviews_hive1(reviewid,product) values (-1,1);
    insert into dbname.reviews_hive1(reviewid,product) values (-2,2);
    insert into dbname.reviews_hive1(reviewid,product) values (-3,3);
    insert into dbname.reviews_hive1(reviewid,product) values (-4,4);
    
    select * from dbname.reviews_hive1;
    \quit
    

    我得到以下结果:

    jsqsh --autoconnect --input-file=./t2.sql --output-file=t2.out
    0 rows affected (total: 3.75s)
    0 rows affected (total: 1.63s)
    1 row affected (total: 0.29s)
    1 row affected (total: 0.27s)
    1 row affected (total: 0.15s)
    1 row affected (total: 0.25s)
    1 row affected (total: 0.26s)
    5 rows in results(first row: 0.22s; total: 0.23s)
    0 rows affected (total: 4.6s)
    0 rows affected (total: 1.65s)
    1 row affected (total: 0.29s)
    1 row affected (total: 0.15s)
    1 row affected (total: 0.25s)
    1 row affected (total: 0.15s)
    4 rows in results(first row: 0.18s; total: 0.18s)
    0 rows affected (total: 3.70s)
    0 rows affected (total: 1.66s)
    1 row affected (total: 0.30s)
    1 row affected (total: 0.26s)
    1 row affected (total: 0.16s)
    1 row affected (total: 0.15s)
    4 rows in results(first row: 0.18s; total: 0.18s)
    
    cat t2.out
    +----+----+--------------+----+
    | F1 | F2 | F3           | F4 |
    +----+----+--------------+----+
    |  0 |  0 | Detroit      |  0 |
    |  1 |  1 | Mt. Pleasant |  1 |
    |  2 |  2 | Marysville   |  2 |
    |  3 |  3 | St. Clair    |  3 |
    |  4 |  4 | Port Huron   |  4 |
    +----+----+--------------+----+
    +----------+---------+
    | REVIEWID | PRODUCT |
    +----------+---------+
    |        0 |       0 |
    |        1 |       1 |
    |        2 |       2 |
    |        3 |       3 |
    +----------+---------+
    +----------+---------+
    | REVIEWID | PRODUCT |
    +----------+---------+
    |       -4 |       4 |
    |       -3 |       3 |
    |       -2 |       2 |
    |       -1 |       1 |
    +----------+---------+
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-14
      • 1970-01-01
      • 2015-04-02
      • 2016-01-12
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多