field1
field2
field3
year
month
day
host
STRING
createdatabaseexternal_partitions;
useexternal_partitions;
createtablelogs(field1string,field2string,field3string)
partitionedby(yearstring,monthstring,daystring,hoststring)
rowformatdelimitedfieldsterminatedby',';
insertintologspartition(year="2013",month="07",day="28",host="host1")values("foo","foo","foo");
insertintologspartition(year="2013",month="07",day="28",host="host2")values("foo","foo","foo");
insertintologspartition(year="2013",month="07",day="29",host="host1")values("foo","foo","foo");
insertintologspartition(year="2013",month="07",day="29",host="host2")values("foo","foo","foo");
insertintologspartition(year="2013",month="08",day="01",host="host1")values("foo","foo","foo");
hdfsdfs-ls
=
hdfsdfs-cat
INSERT
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db
Found1items
drwxrwxrwt-impalahive02013-08-0712:24/user/impala/warehouse/external_partitions.db/logs
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db/logs
Found1items
drwxr-xr-x-impalahive02013-08-0712:24/user/impala/warehouse/external_partitions.db/logs/year=2013
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db/logs/year=2013
Found2items
drwxr-xr-x-impalahive02013-08-0712:23/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07
drwxr-xr-x-impalahive02013-08-0712:24/user/impala/warehouse/external_partitions.db/logs/year=2013/month=08
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07
Found2items
drwxr-xr-x-impalahive02013-08-0712:22/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28
drwxr-xr-x-impalahive02013-08-0712:23/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=29
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28
Found2items
drwxr-xr-x-impalahive02013-08-0712:21/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28/host=host1
drwxr-xr-x-impalahive02013-08-0712:22/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28/host=host2
$hdfsdfs-ls/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28/host=host1
Found1items
-rw-r--r--3impalahive122013-08-0712:21/user/impala/warehouse/external_partiti
ons.db/logs/year=2013/month=07/day=28/host=host1/3981726974111751120--8907184999369517436_822630111_data.0
$hdfsdfs-cat/user/impala/warehouse/external_partitions.db/logs/year=2013/month=07/day=28/\
host=host1/3981726974111751120--8907184999369517436_822630111_data.0
foo,foo,foo
hdfsdfs-mkdir
hdfs
$hdfsdfs-mkdir-p/user/impala/data/logs/year=2013/month=07/day=28/host=host1
$hdfsdfs-mkdir-p/user/impala/data/logs/year=2013/month=07/day=28/host=host2
$hdfsdfs-mkdir-p/user/impala/data/logs/year=2013/month=07/day=28/host=host1
$hdfsdfs-mkdir-p/user/impala/data/logs/year=2013/month=07/day=29/host=host1
$hdfsdfs-mkdir-p/user/impala/data/logs/year=2013/month=08/day=01/host=host1
INSERT
$cat>dummy_log_data
bar,baz,bletch
$hdfsdfs-mkdir-p/user/impala/data/external_partitions/year=2013/month=08/day=01/host=host1
$hdfsdfs-mkdir-p/user/impala/data/external_partitions/year=2013/month=07/day=28/host=host1
$hdfsdfs-mkdir-p/user/impala/data/external_partitions/year=2013/month=07/day=28/host=host2
$hdfsdfs-mkdir-p/user/impala/data/external_partitions/year=2013/month=07/day=29/host=host1
$hdfsdfs-putdummy_log_data/user/impala/data/logs/year=2013/month=07/day=28/host=host1
$hdfsdfs-putdummy_log_data/user/impala/data/logs/year=2013/month=07/day=28/host=host2
$hdfsdfs-putdummy_log_data/user/impala/data/logs/year=2013/month=07/day=29/host=host1
$hdfsdfs-putdummy_log_data/user/impala/data/logs/year=2013/month=08/day=01/host=host1
LOCATION
useexternal_partitions;
altertablelogsrenametologs_original;
createexternaltablelogs(field1string,field2string,field3string)
partitionedby(yearstring,monthstring,daystring,hoststring)
rowformatdelimitedfieldsterminatedby','
location'/user/impala/data/logs';
ALTERTABLE
altertablelogsaddpartition(year="2013",month="07",day="28",host="host1")
altertablelog_typeaddpartition(year="2013",month="07",day="28",host="host2");
altertablelog_typeaddpartition(year="2013",month="07",day="29",host="host1");
altertablelog_typeaddpartition(year="2013",month="08",day="01",host="host1");
REFRESH
SELECT*
LIMIT
refreshlog_type;
select*fromlog_typelimit100;
+--------+--------+--------+------+-------+-----+-------+
|field1 |field2 |field3 |year |month |day |host |
+--------+--------+--------+------+-------+-----+-------+
|bar |baz |bletch |2013 |07 |28 |host1 |
|bar |baz |bletch |2013 |08 |01 |host1 |
|bar |baz |bletch |2013 |07 |29 |host1 |
|bar |baz |bletch |2013 |07 |28 |host2 |
+--------+--------+--------+------+-------+-----+-------+