I have trouble when using hive conf in INSERT INTO a partition table.
Below is my code
set PERIOD = 202305;
set DAY=concat(substr(${hiveconf:PERIOD},1,4),'-',substr(${hiveconf:PERIOD},5,2),'-01');
-- DAY result = 20230501
set COMPUTE_MONTH = date_format(add_months(from_unixtime(unix_timestamp(${hiveconf:DAY}, 'yyyy-MM-dd'), 'yyyy-MM-dd'), -1), 'yyyyMM');
--COMPUTE_MONTH = 202304
-- Case 1
ALTER TABLE db.table DROP PARTITION (snapshot = ${hiveconf:PERIOD});
INSERT INTO TABLE db.table PARTITION (snapshot = ${hiveconf:PERIOD})
SELECT
...
-- Case 2
ALTER TABLE db.table DROP PARTITION (snapshot = ${hiveconf:COMPUTE_MONTH});
INSERT INTO TABLE db.table PARTITION (snapshot = ${hiveconf:COMPUTE_MONTH})
SELECT
...
- Case 1 run well with hiveconf PERIOD
- Case 2 return error as attached image case_2_log_returned
I need help, how to use COMPUTE_MONTH (previous month of PERIOD) in INSERT INTO a partition table in this case.
Thanks in advance.