ITPub博客

首页 > 大数据 > 数据分析 > impala下的表查询测试(refresh)

impala下的表查询测试(refresh)

原创 数据分析 作者:jack22220613 时间:2015-03-23 14:04:45 0 删除 编辑
测试:
create table c (n1 int) PARTITIONED by (hour int) row format delimited   fields terminated by ','  stored as textfile;

3个文件:
file1  1rows
file2  2rows
file3  5rows

[root@cdh0 cuich]# touch file1.csv
[root@cdh0 cuich]# touch file2.csv
[root@cdh0 cuich]# touch file3.csv
[root@cdh0 cuich]#
[root@cdh0 cuich]# echo 0 >> file1.csv
[root@cdh0 cuich]#
[root@cdh0 cuich]# echo 2 >> file2.csv
[root@cdh0 cuich]# echo 22 >> file2.csv
[root@cdh0 cuich]#
[root@cdh0 cuich]# echo 3 >> file3.csv
[root@cdh0 cuich]# echo 33 >> file3.csv
[root@cdh0 cuich]# echo 333 >> file3.csv
[root@cdh0 cuich]# echo 3333 >> file3.csv
[root@cdh0 cuich]# echo 33333 >> file3.csv

[cdh1:21000] > create table c (n1 int) PARTITIONED by (hour int) row format delimited   fields terminated by ','  stored as textfile;
Query: create table c (n1 int) PARTITIONED by (hour int) row format delimited   fields terminated by ','  stored as textfile

Fetched 0 row(s) in 0.07s
[cdh1:21000] >
[cdh1:21000] > alter table c add partition (hour=0);
Query: alter table c add partition (hour=0)
[cdh1:21000] >

case 1
  put file1;
  select count(*) from c;
  select * from c;

[root@cdh0 cuich]# hadoop fs -put file1.csv /user/hive/warehouse/db1.db/c/hour=0/
[cdh1:21000] > select count(*) from c;
Query: select count(*) from c
+----------+
| count(*) |
+----------+
| 0        |
+----------+
Fetched 1 row(s) in 1.06s
[cdh1:21000] >
[cdh1:21000] > select * from c;
Query: select * from c

Fetched 0 row(s) in 0.01s

case 2:  
  refresh c;
  select count(*) from c;
    
[cdh1:21000] >  refresh c;
Query: refresh c

Fetched 0 row(s) in 0.11s
[cdh1:21000] >
[cdh1:21000] >
[cdh1:21000] > select count(*) from c;
Query: select count(*) from c
+----------+
| count(*) |
+----------+
| 1        |
+----------+
Fetched 1 row(s) in 1.11s

case 3:  
  rm file1;
  select count(*) from c;
  select * from c;

[root@cdh0 ~]# hadoop fs -ls /user/hive/warehouse/db1.db/c/hour=0/
Found 1 items
-rw-r--r--   3 root hive          2 2015-03-23 13:47 /user/hive/warehouse/db1.db/c/hour=0/file1.csv
[root@cdh0 ~]#
[root@cdh0 ~]#
[root@cdh0 ~]# hadoop fs -rm /user/hive/warehouse/db1.db/c/hour=0/file1.csv
15/03/23 13:52:07 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes.
Moved: 'hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv' to trash at: hdfs://cdh0:8020/user/root/.Trash/Current
[root@cdh0 ~]#
[root@cdh0 ~]# hadoop fs -ls /user/hive/warehouse/db1.db/c/hour=0/
[root@cdh0 ~]#

[cdh1:21000] >  select count(*) from c;
Query: select count(*) from c
WARNINGS: Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory


Backend 0:Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory

[cdh1:21000] >
[cdh1:21000] > select * from c;
Query: select * from c
WARNINGS: Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory


Backend 0:Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory


case 4:  
  put file2;
  select count(*) from c;
  select * from c;

[root@cdh0 cuich]# hadoop fs -put file2.csv /user/hive/warehouse/db1.db/c/hour=0/
[root@cdh0 cuich]#
[cdh1:21000] >  select count(*) from c;
Query: select count(*) from c
WARNINGS: Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory


Backend 0:Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory

[cdh1:21000] >
[cdh1:21000] > select * from c;
Query: select * from c
WARNINGS: Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory


Backend 0:Failed to open HDFS file hdfs://cdh0:8020/user/hive/warehouse/db1.db/c/hour=0/file1.csv
Error(2): No such file or directory

[cdh1:21000] >

case 5:  
  修改file1,put file1;
  select count(*) from c;
  select * from c;

[root@cdh0 cuich]# echo 1 >> file1.csv
[root@cdh0 cuich]# hadoop fs -put file1.csv /user/hive/warehouse/db1.db/c/hour=0/

[cdh1:21000] >  select count(*) from c;
Query: select count(*) from c
+----------+
| count(*) |
+----------+
| 2        |
+----------+
Fetched 1 row(s) in 1.11s
[cdh1:21000] >
[cdh1:21000] > select * from c;
Query: select * from c
+----+------+
| n1 | hour |
+----+------+
| 0  | 0    |
| 1  | 0    |
+----+------+
Fetched 2 row(s) in 0.74s

case 6:  
  refresh c;
  select count(*) from c;
  select * from c;

[cdh1:21000] >  refresh c
             > ;
Query: refresh c

Fetched 0 row(s) in 0.12s
[cdh1:21000] >
[cdh1:21000] > select count(*) from c;
Query: select count(*) from c
+----------+
| count(*) |
+----------+
| 4        |
+----------+
Fetched 1 row(s) in 1.11s
[cdh1:21000] >
[cdh1:21000] > select * from c;
Query: select * from c
+----+------+
| n1 | hour |
+----+------+
| 2  | 0    |
| 22 | 0    |
| 0  | 0    |
| 1  | 0    |
+----+------+
Fetched 4 row(s) in 0.74s

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10037372/viewspace-1470376/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-05-13

  • 博文量
    94
  • 访问量
    358090