๐ปTech/๐HIVE
[Hive] sequence ์ปฌ๋ผ ์์ฑ ๋ฐฉ๋ฒ
_viper_
2021. 4. 28. 16:52
๋ฐ์ํ
๐โ๏ธ ROW_NUMBER() OVER() ๊ตฌ๋ฌธ์ ์ฌ์ฉํด์ seq ๋ฒํธ๋ฅผ ์ ์ฅ
## ๊ธฐ์กด ํ
์ด๋ธ์์ seq ์ปฌ๋ผ์ ์ถ๊ฐํ ํ
์ด๋ธ ์์ฑ
CREATE TABLE new_table(
seq int,
code string,
description string,
total_emp int,
salary int
)
STORE AS parquet;
## ๊ธฐ์กด ํ
์ด๋ธ์ ROW_NUMBER() OVER() ํฉ์ ์ฌ์ฉํด์ seq ์ปฌ๋ผ ์ถ๊ฐํ ๋ฐ์ดํฐ insert
insert overwrite table new_table
select * from (
select ROW_NUMBER() OVER() as RNUM, *
from old_table) a where a.RNUM <= 100000000;