Trino displays deleted rows from Hive ACID tables before compaction runs
Trino version
483
Please describe the bug
- Description
When accessing a CDP Private Cloud Base cluster while reading a Hive ACID table with rows deleted before compaction has run, Trino displays the deleted rows.
Once compaction has run, the behavior is correct -> the deleted rows are no longer displayed in Trino.
- Example
with beeline connected to cdp cluster
create table t1 as select 1 x;
insert into t1 values (2);
select * from t1;
+-------+
| t1.x |
+-------+
| 1 |
| 2 |
+-------+
delete from t1 where x=1;
select * from t1;
+-------+
| t1.x |
+-------+
| 2 |
+-------+
with trino client the deleted is still there
trino:default> select * from t1;
x
---
1
2
(2 rows)
- Expected behaviour
the deleted line is absent in trino too
trino:default> select * from t1;
x
---
2
(1 rows)- Proposed fix
in CDP the orc files in the delete_delta folders are named bucket_XXXXX_YY
when trino reads the hive table files it truncate the delete_delta path containing files with attemptid (_YY)
from bucket_XXXXX_YY to bucket_XXXXX
if (hasAttemptId(fileName)) {
return directory.appendPath(fileName.substring(0, fileName.lastIndexOf('_')));
} and later when the file is processed it is silentily dropped because it doesn't find it
The solution would be not to rename the bucket file by eliminating the if (hasAttemptId(filename)) block.
Source: trinodb/trino