์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[TIL] AWS Athena์—์„œ ๊ธฐ์กด ํŒŒํ‹ฐ์…˜ dropํ•˜๊ณ , ์‹ ๊ทœ ํŒŒํ‹ฐ์…˜ ์ƒ์„ฑ 220920

CLOUD/AWS

by ์—์Šคํ”„๋ฆฌํ„ฐ 2022. 9. 20. 10:48

๋ณธ๋ฌธ

728x90
๐Ÿ’ก Today I Learned ์š”์•ฝ (5ํšŒ์ฐจ)
- AWS Athena์—์„œ ํŒŒํ‹ฐ์…˜์ด ์ž˜๋ชป ์ƒ์„ฑ๋˜์—ˆ์„ ๊ฒฝ์šฐ alter table์„ ์‚ฌ์šฉํ•ด์„œ ๊ธฐ์กด ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•˜๊ณ , ์ƒˆ๋กœ์šด ํŒŒํ‹ฐ์…˜ ์ƒ์„ฑ ๊ฐ€๋Šฅ

 

AWS Athena์—์„œ ๊ธฐ์กด ํŒŒํ‹ฐ์…˜ dropํ•˜๊ณ , ์‹ ๊ทœ ํŒŒํ‹ฐ์…˜ ์ƒ์„ฑ

Athena์—์„œ ์‹ค์ˆ˜๋กœ ํŒŒํ‹ฐ์…˜์„ ์ž˜๋ชป ์ƒ์„ฑํ•œ ๊ฒฝ์šฐ(s3 ๊ฒฝ๋กœ๋ฅผ ์ž˜๋ชป ์ž…๋ ฅํ–ˆ๋‹ค๋˜๊ฐ€ ํ•˜๋Š” ์ด์œ ๋กœ) ๊ธฐ์กด ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•˜๊ณ , ์‹ ๊ทœ ํŒŒํ‹ฐ์…˜์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Œ.

-- ๊ธฐ์กด ํŒŒํ‹ฐ์…˜ ์‚ญ์ œ 
ALTER TABLE {ํ…Œ์ด๋ธ”๋ช…}
DROP IF EXISTS PARTITION ({ํŒŒํ‹ฐ์…˜ ํ‚ค} = {ํŒŒํ‹ฐ์…˜ ๊ฐ’});
-- ํŒŒํ‹ฐ์…˜ ํ‚ค ๋Œ€์ฒด
ALTER table {ํ…Œ์ด๋ธ”๋ช…} ADD IF NOT EXISTS
PARTITION ({ํŒŒํ‹ฐ์…˜ ํ‚ค} = {ํŒŒํ‹ฐ์…˜ ๊ฐ’}) LOCATION {s3 ๊ฒฝ๋กœ ๊ฐ’};

-- ์˜ˆ์ œ ์ฟผ๋ฆฌ
ALTER TABLE database.table_name
DROP IF EXISTS PARTITION (partition_key = '2022-09-03');

ALTER table database.table_name ADD IF NOT EXISTS
PARTITION (partition_key = '2022-09') LOCATION 's3://data/2022/09/03';

#aws ๊ด€๋ จ ์ž‘์„ฑํ–ˆ๋˜ ๊ฒƒ:

#aws ๊ด€๋ จ ๋ฆฌ์„œ์น˜ํ•œ ๊ฒƒ:

ํƒœ๊ทธ

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ

๋Œ“๊ธ€ ์˜์—ญ