bigsql hbase集成

aemubtdh  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(444)

我是bigsql的新手。我知道hbase可以与bigsql集成。在创建hbase表之后和之前,我曾尝试执行bigsql hbase create命令,但是我得到了下面提到的错误。
sql1:

  1. CREATE HBASE TABLE dbname.reviews_hive (
  2. REVIEWID int,
  3. PRODUCT int
  4. )
  5. COLUMN MAPPING
  6. (
  7. key MAPPED BY (REVIEWID),
  8. summary:product MAPPED BY (PRODUCT)
  9. );

(或)
sql2:

  1. CREATE HBASE TABLE dbname.reviews_hive (
  2. REVIEWID int primary key not null,
  3. PRODUCT int
  4. )
  5. COLUMN MAPPING
  6. (
  7. key MAPPED BY (REVIEWID),
  8. summary:product MAPPED BY (PRODUCT)
  9. );

错误:[状态:42601][代码:-104]:在“(”之后发现意外标记“key”。预期的令牌可能包括:“。。sqlcode=-104,sqlstate=42601,driver=3.68.61
有人能帮我吗?
提前谢谢各位。

ffdz8vbo

ffdz8vbo1#

我假设你在big insights 4.x上。在biginsights 4之前,bigsql的sql接口仅在bigsql v1中可用。
当我运行以下测试脚本(包括您的两个create hbase table语句)(我通过jsqsh和db2命令行运行了这个示例)时,我得到了以下结果:

  1. \connect bigsql
  2. drop table if exists stack.issue3;
  3. create hbase table if not exists stack.issue3 (
  4. f1 integer,
  5. f2 integer,
  6. f3 varchar(200),
  7. f4 integer
  8. )
  9. column mapping(
  10. key mapped by (f1, f2),
  11. cf0:f3 mapped by (f3,f4)
  12. encoding delimited
  13. fields terminated by '\b'
  14. )
  15. default encoding binary
  16. ;
  17. insert into stack.issue3 (f1,f2,f3,f4) values (0,0,'Detroit',0);
  18. insert into stack.issue3 (f1,f2,f3,f4) values (1,1,'Mt. Pleasant',1);
  19. insert into stack.issue3 (f1,f2,f3,f4) values (2,2,'Marysville',2);
  20. insert into stack.issue3 (f1,f2,f3,f4) values (3,3,'St. Clair',3);
  21. insert into stack.issue3 (f1,f2,f3,f4) values (4,4,'Port Huron',4);
  22. select * from stack.issue3;
  23. drop table if exists dbname.reviews_hive;
  24. CREATE HBASE TABLE if not exists dbname.reviews_hive (
  25. REVIEWID int,
  26. PRODUCT int
  27. )
  28. COLUMN MAPPING (
  29. key MAPPED BY (REVIEWID),
  30. summary:product MAPPED BY (PRODUCT)
  31. );
  32. insert into dbname.reviews_hive(reviewid,product) values (0,0);
  33. insert into dbname.reviews_hive(reviewid,product) values (1,1);
  34. insert into dbname.reviews_hive(reviewid,product) values (2,2);
  35. insert into dbname.reviews_hive(reviewid,product) values (3,3);
  36. select * from dbname.reviews_hive;
  37. drop table if exists dbname.reviews_hive1;
  38. CREATE HBASE TABLE if not exists dbname.reviews_hive1 (
  39. REVIEWID int primary key not null,
  40. PRODUCT int
  41. )
  42. COLUMN MAPPING (
  43. key MAPPED BY (REVIEWID),
  44. summary:product MAPPED BY (PRODUCT)
  45. );
  46. insert into dbname.reviews_hive1(reviewid,product) values (-1,1);
  47. insert into dbname.reviews_hive1(reviewid,product) values (-2,2);
  48. insert into dbname.reviews_hive1(reviewid,product) values (-3,3);
  49. insert into dbname.reviews_hive1(reviewid,product) values (-4,4);
  50. select * from dbname.reviews_hive1;
  51. \quit

我得到以下结果:

  1. jsqsh --autoconnect --input-file=./t2.sql --output-file=t2.out
  2. 0 rows affected (total: 3.75s)
  3. 0 rows affected (total: 1.63s)
  4. 1 row affected (total: 0.29s)
  5. 1 row affected (total: 0.27s)
  6. 1 row affected (total: 0.15s)
  7. 1 row affected (total: 0.25s)
  8. 1 row affected (total: 0.26s)
  9. 5 rows in results(first row: 0.22s; total: 0.23s)
  10. 0 rows affected (total: 4.6s)
  11. 0 rows affected (total: 1.65s)
  12. 1 row affected (total: 0.29s)
  13. 1 row affected (total: 0.15s)
  14. 1 row affected (total: 0.25s)
  15. 1 row affected (total: 0.15s)
  16. 4 rows in results(first row: 0.18s; total: 0.18s)
  17. 0 rows affected (total: 3.70s)
  18. 0 rows affected (total: 1.66s)
  19. 1 row affected (total: 0.30s)
  20. 1 row affected (total: 0.26s)
  21. 1 row affected (total: 0.16s)
  22. 1 row affected (total: 0.15s)
  23. 4 rows in results(first row: 0.18s; total: 0.18s)
  24. cat t2.out
  25. +----+----+--------------+----+
  26. | F1 | F2 | F3 | F4 |
  27. +----+----+--------------+----+
  28. | 0 | 0 | Detroit | 0 |
  29. | 1 | 1 | Mt. Pleasant | 1 |
  30. | 2 | 2 | Marysville | 2 |
  31. | 3 | 3 | St. Clair | 3 |
  32. | 4 | 4 | Port Huron | 4 |
  33. +----+----+--------------+----+
  34. +----------+---------+
  35. | REVIEWID | PRODUCT |
  36. +----------+---------+
  37. | 0 | 0 |
  38. | 1 | 1 |
  39. | 2 | 2 |
  40. | 3 | 3 |
  41. +----------+---------+
  42. +----------+---------+
  43. | REVIEWID | PRODUCT |
  44. +----------+---------+
  45. | -4 | 4 |
  46. | -3 | 3 |
  47. | -2 | 2 |
  48. | -1 | 1 |
  49. +----------+---------+
展开查看全部

相关问题