๋ฐ์ํ
๐ก hive query ์์ ๋ณ์๋ฅผ ์ ๋ ฅ๋ฐ์,๋ณ์๋ฅผ ํ์ฉํ๋ ๋ฐฉ๋ฒ์ ์์๋ณธ๋ค.
hive query ์์
์๋์ ๊ฐ์ ๋ฐฉ์์ผ๋ก hivevar๋ฅผ ์ ์ธํด์ค๋ค.
SET hivevar:from_month = SOMETHING;
๋ณ์๋ฅผ ์ ์ธํ๊ณ , ์์ฑํ ๋ณ์๋ฅผ ์ฌ์ฉ๋ query๋ฅผ ์์ฑํด๋ณด๋๋ก ํ๋ค.
๋ณ์๋ฅผ string ๊ฐ์ด ์๋,
์ฟผ๋ฆฌ๋ฌธ์ผ๋ก ์ ์ธ ํ ์ ๋ ์๋ค.
SET hivevar:qs = date_format(add_months(trunc("${hivevar:from}", "MM)
, CASE WHEN date_format("${hivevar:from}", "dd') < 17 THEN -2
ELSE -1
END)
, 'yyyy-MM');
oozie workflow์์ 'from' ๊ณผ 'to'๋ผ๋ ๋ ์ง ๋ณ์๋ฅผ ์ ๋ ฅ ๋ฐ๊ณ .
์ด ๋ณ์๋ค์ ํ์ฉํด๋ณธ๋ค.
SET hivevar:from_month = date_format("${hivevar:from}", 'YYYY-MM');
SET hivevar:to_month = date_format("${hivevar: to}", "YYYY-MM');
SET hivevar:qs = date_format(add_months(trunc("${hivevar:from}", "MM)
, CASE WHEN date_format("${hivevar:from}", "dd') < 17 THEN -2
ELSE -1
END)
, 'yyyy-MM');
SELECT $(hivevar:from_month) AS from month
, $(hivevar:to_month) AS to_month
, "${hivevar:from)" AS from_conditon
, "${hivevar:to)" AS to_conditon
, $(hivevar:qs) AS qs
๋ฐ์ํ