Hello,
We have a business request to compare the evolution in a certain delta table.
We would like to compare the latest version of the table with the previous one using Delta time travel.
The main issue we are facing is to retrieve programmatically using SQL the N-1 version and give it as a parameter to our SQL query.
The idea is to get something like this:
%sql
select * from schedule@vN
except all
select * from schedule@vN-1
We know that the latest version can be used by simply using the delta table name (as it uses by default the last version), but how can we retrieve the previous delta version.
We tried to use the 'hivevar' variable (like below ) but we are getting an error since the hivevar is not evaluated.
SET hive.variable.substitute=true;
SET hivevar:ver=SELECT VERSION FROM (DESCRIBE HISTORY schema.my_table) LIMIT 1;
SELECT * FROM schema.my_table VERSION AS OF ${hivevar:ver};
The error code below:
- Error in SQL stateùent: parseException:
missing INTEGER_VALUE at 'SELECT'(line 1, pos 84)
Any idea how to achieve this ?