버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

코드 블럭
languagesql
linenumberstrue
insert into logs partition (year="2013", month="07", day="28", host="host1") values ("foo","foo","foo");

External Table 생성하기

Managed Table 대신 저장 위치를 별도로 지정하여 생성할 수 있는 External Table을 생성하려면 다음의 쿼리를 실행합니다.

코드 블럭
languagesql
linenumberstrue
create external table logs (
    field1 string, 
    field2 string, 
    field3 string
)
  partitioned by (year string, month string, day string, host string)
  row format delimited fields terminated by ','
  location '/user/impala/data/logs';

이 경우 새로운 파티션을 추가하기 위해서는 다음의 쿼리를 실행할 수 있습니다.

코드 블럭
languageruby
linenumberstrue
alter table logs add partition (year="2013",month="07",day="28",host="host1")

이제 마지막으로 Refresh를 실행합니다.

코드 블럭
languagetext
linenumberstrue
refresh log_type;
select * from log_type limit 100;
+--------+--------+--------+------+-------+-----+-------+
| 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 |
+--------+--------+--------+------+-------+-----+-------+