PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/hbase-handler/src/test/queries/hbase_queries.q

#
text | 160 lines | 131 code | 29 blank | 0 comment | 0 complexity | 58fe203981c55fe75b81f07d166de483 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. DROP TABLE hbase_table_1;
  2. CREATE TABLE hbase_table_1(key int, value string)
  3. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  4. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "cf:string")
  5. TBLPROPERTIES ("hbase.table.name" = "hbase_table_0");
  6. DESCRIBE EXTENDED hbase_table_1;
  7. select * from hbase_table_1;
  8. EXPLAIN FROM src INSERT OVERWRITE TABLE hbase_table_1 SELECT * WHERE (key%2)=0;
  9. FROM src INSERT OVERWRITE TABLE hbase_table_1 SELECT * WHERE (key%2)=0;
  10. DROP TABLE hbase_table_2;
  11. CREATE EXTERNAL TABLE hbase_table_2(key int, value string)
  12. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  13. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "cf:string")
  14. TBLPROPERTIES ("hbase.table.name" = "hbase_table_0");
  15. EXPLAIN
  16. SELECT Y.*
  17. FROM
  18. (SELECT hbase_table_1.* FROM hbase_table_1) x
  19. JOIN
  20. (SELECT src.* FROM src) Y
  21. ON (x.key = Y.key)
  22. ORDER BY key, value LIMIT 20;
  23. SELECT Y.*
  24. FROM
  25. (SELECT hbase_table_1.* FROM hbase_table_1) x
  26. JOIN
  27. (SELECT src.* FROM src) Y
  28. ON (x.key = Y.key)
  29. ORDER BY key, value LIMIT 20;
  30. EXPLAIN
  31. SELECT Y.*
  32. FROM
  33. (SELECT hbase_table_1.* FROM hbase_table_1 WHERE hbase_table_1.key > 100) x
  34. JOIN
  35. (SELECT hbase_table_2.* FROM hbase_table_2 WHERE hbase_table_2.key < 120) Y
  36. ON (x.key = Y.key)
  37. ORDER BY key, value;
  38. SELECT Y.*
  39. FROM
  40. (SELECT hbase_table_1.* FROM hbase_table_1 WHERE hbase_table_1.key > 100) x
  41. JOIN
  42. (SELECT hbase_table_2.* FROM hbase_table_2 WHERE hbase_table_2.key < 120) Y
  43. ON (x.key = Y.key)
  44. ORDER BY key,value;
  45. DROP TABLE empty_hbase_table;
  46. CREATE TABLE empty_hbase_table(key int, value string)
  47. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  48. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "cf:string");
  49. DROP TABLE empty_normal_table;
  50. CREATE TABLE empty_normal_table(key int, value string);
  51. select * from (select count(1) as c from empty_normal_table union all select count(1) as c from empty_hbase_table) x order by c;
  52. select * from (select count(1) c from empty_normal_table union all select count(1) as c from hbase_table_1) x order by c;
  53. select * from (select count(1) c from src union all select count(1) as c from empty_hbase_table) x order by c;
  54. select * from (select count(1) c from src union all select count(1) as c from hbase_table_1) x order by c;
  55. CREATE TABLE hbase_table_3(key int, value string, count int)
  56. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  57. WITH SERDEPROPERTIES (
  58. "hbase.columns.mapping" = "cf:val,cf2:count"
  59. );
  60. EXPLAIN
  61. INSERT OVERWRITE TABLE hbase_table_3
  62. SELECT x.key, x.value, Y.count
  63. FROM
  64. (SELECT hbase_table_1.* FROM hbase_table_1) x
  65. JOIN
  66. (SELECT src.key, count(src.key) as count FROM src GROUP BY src.key) Y
  67. ON (x.key = Y.key);
  68. INSERT OVERWRITE TABLE hbase_table_3
  69. SELECT x.key, x.value, Y.count
  70. FROM
  71. (SELECT hbase_table_1.* FROM hbase_table_1) x
  72. JOIN
  73. (SELECT src.key, count(src.key) as count FROM src GROUP BY src.key) Y
  74. ON (x.key = Y.key);
  75. select count(1) from hbase_table_3;
  76. select * from hbase_table_3 order by key, value limit 5;
  77. select key, count from hbase_table_3 order by key, count desc limit 5;
  78. DROP TABLE hbase_table_4;
  79. CREATE TABLE hbase_table_4(key int, value1 string, value2 int, value3 int)
  80. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  81. WITH SERDEPROPERTIES (
  82. "hbase.columns.mapping" = "a:b,a:c,d:e"
  83. );
  84. INSERT OVERWRITE TABLE hbase_table_4 SELECT key, value, key+1, key+2
  85. FROM src WHERE key=98 OR key=100;
  86. SELECT * FROM hbase_table_4 ORDER BY key;
  87. DROP TABLE hbase_table_5;
  88. CREATE EXTERNAL TABLE hbase_table_5(key int, value map<string,string>)
  89. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  90. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "a:")
  91. TBLPROPERTIES ("hbase.table.name" = "hbase_table_4");
  92. SELECT * FROM hbase_table_5 ORDER BY key;
  93. DROP TABLE hbase_table_6;
  94. CREATE TABLE hbase_table_6(key int, value map<string,string>)
  95. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  96. WITH SERDEPROPERTIES (
  97. "hbase.columns.mapping" = ":key,cf:"
  98. );
  99. INSERT OVERWRITE TABLE hbase_table_6 SELECT key, map(value, key) FROM src
  100. WHERE key=98 OR key=100;
  101. SELECT * FROM hbase_table_6 ORDER BY key;
  102. DROP TABLE hbase_table_7;
  103. CREATE TABLE hbase_table_7(value map<string,string>, key int)
  104. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  105. WITH SERDEPROPERTIES (
  106. "hbase.columns.mapping" = "cf:,:key"
  107. );
  108. INSERT OVERWRITE TABLE hbase_table_7
  109. SELECT map(value, key, upper(value), key+1), key FROM src
  110. WHERE key=98 OR key=100;
  111. SELECT * FROM hbase_table_7 ORDER BY key;
  112. set hive.hbase.wal.enabled=false;
  113. DROP TABLE hbase_table_8;
  114. CREATE TABLE hbase_table_8(key int, value1 string, value2 int, value3 int)
  115. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  116. WITH SERDEPROPERTIES (
  117. "hbase.columns.mapping" = "a:b,a:c,d:e"
  118. );
  119. INSERT OVERWRITE TABLE hbase_table_8 SELECT key, value, key+1, key+2
  120. FROM src WHERE key=98 OR key=100;
  121. SELECT * FROM hbase_table_8 ORDER BY key;
  122. DROP TABLE hbase_table_1;
  123. DROP TABLE hbase_table_2;
  124. DROP TABLE hbase_table_3;
  125. DROP TABLE hbase_table_4;
  126. DROP TABLE hbase_table_5;
  127. DROP TABLE hbase_table_6;
  128. DROP TABLE hbase_table_7;
  129. DROP TABLE hbase_table_8;
  130. DROP TABLE empty_hbase_table;
  131. DROP TABLE empty_normal_table;